@woosh/meep-engine 2.54.0 → 2.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/view/node-graph/PortView.js +2 -2
- package/package.json +1 -1
- package/src/core/__module.js +1 -1
- package/src/core/binary/BinaryBuffer.js +2 -1
- package/src/core/cache/Cache.js +1 -1
- package/src/core/cache/LoadingCache.js +10 -5
- package/src/core/collection/Stack.js +11 -14
- package/src/core/collection/array/array_contains_duplicates.js +5 -2
- package/src/core/collection/array/array_contains_duplicates.spec.js +14 -0
- package/src/core/collection/array/array_copy_entire.js +6 -11
- package/src/core/collection/array/array_get_index_in_range.js +5 -0
- package/src/core/collection/array/array_get_index_in_range.spec.js +16 -0
- package/src/core/collection/array/array_remove_element.js +6 -9
- package/src/core/collection/array/array_remove_first.js +13 -6
- package/src/core/collection/array/array_remove_first.spec.js +39 -0
- package/src/core/collection/array/binarySearchHighIndex.spec.js +10 -9
- package/src/core/collection/array/groupArrayBy.js +1 -1
- package/src/core/collection/array/isArrayEqual.js +4 -1
- package/src/core/collection/array/randomizeArrayElementOrder.js +1 -0
- package/src/core/collection/array/randomizeArrayElementOrder.spec.js +27 -0
- package/src/core/collection/heap/Uin32Heap.spec.js +100 -0
- package/src/core/collection/heap/Uint32Heap.js +16 -7
- package/src/core/collection/list/List.js +1 -0
- package/src/core/collection/{HashMap.js → map/HashMap.js} +10 -10
- package/src/core/collection/{HashMap.spec.js → map/HashMap.spec.js} +1 -1
- package/src/core/collection/{ObservedMap.js → map/ObservedMap.js} +1 -1
- package/src/core/collection/{HashSet.js → set/HashSet.js} +4 -3
- package/src/core/collection/{Set.d.ts → set/Set.d.ts} +1 -1
- package/src/core/collection/{Set.js → set/Set.js} +17 -14
- package/src/core/function/FunctionCompiler.js +4 -4
- package/src/core/function/Functions.js +0 -19
- package/src/core/geom/2d/aabb/AABB2.js +1 -1
- package/src/core/geom/3d/SurfacePoint3.js +30 -20
- package/src/core/geom/3d/SurfacePoint3.spec.js +116 -0
- package/src/core/geom/3d/aabb/AABB3.js +13 -10
- package/src/core/geom/3d/aabb/{aabb3_array_contains_point.js → aabb3_array_intersects_point.js} +4 -1
- package/src/core/geom/3d/aabb/aabb3_from_min_max.js +25 -1
- package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +2 -25
- package/src/core/geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js +5 -1
- package/src/core/geom/3d/apply_mat4_transform_to_direction_v3_array.js +5 -1
- package/src/core/geom/3d/apply_mat4_transform_to_v3_array.js +5 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +2 -2
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_calc_edges.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.spec.js +26 -0
- package/src/core/geom/3d/v3_compute_triangle_normal.spec.js +18 -0
- package/src/core/geom/Vector2.js +1 -1
- package/src/core/geom/Vector3.js +1 -1
- package/src/core/geom/packing/miniball/Miniball.spec.js +24 -0
- package/src/core/math/statistics/computeStatisticalPartialMedian.js +2 -2
- package/src/core/model/ObservedInteger.js +12 -7
- package/src/core/model/ObservedString.js +10 -8
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
- package/src/core/model/object/ImmutableObjectPool.js +1 -1
- package/src/core/model/object/read_property.js +2 -2
- package/src/core/model/object/write_property.js +3 -3
- package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +1 -1
- package/src/core/primitives/numbers/compareNumbers.js +4 -4
- package/src/core/primitives/numbers/number_compare_ascending.js +9 -0
- package/src/core/primitives/numbers/number_compare_ascending.spec.js +9 -0
- package/src/core/primitives/numbers/number_compare_descending.js +9 -0
- package/src/core/primitives/numbers/number_compare_descending.spec.js +9 -0
- package/src/core/primitives/numbers/number_format_by_thousands.spec.js +12 -0
- package/src/core/primitives/numbers/number_pretty_print.js +1 -1
- package/src/core/primitives/strings/compareStrings.spec.js +12 -0
- package/src/core/primitives/strings/string_capitalize.js +15 -0
- package/src/core/primitives/strings/string_capitalize.spec.js +13 -0
- package/src/core/primitives/strings/string_compute_byte_size.js +21 -0
- package/src/core/primitives/strings/string_compute_common_prefix.js +44 -0
- package/src/core/primitives/strings/string_compute_common_prefix.spec.js +23 -0
- package/src/core/primitives/strings/string_format_camel_to_kebab.js +9 -0
- package/src/core/primitives/strings/string_format_camel_to_kebab.spec.js +8 -0
- package/src/core/primitives/strings/string_format_kebab_to_underscore.js +8 -0
- package/src/core/time/current_time_in_seconds.js +11 -0
- package/src/engine/Clock.js +3 -13
- package/src/engine/animation/curve/AnimationCurve.spec.js +27 -0
- package/src/engine/asset/AssetManager.js +5 -5
- package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
- package/src/engine/ecs/EntityBlueprint.js +8 -10
- package/src/engine/ecs/EntityManager.js +8 -1
- package/src/engine/ecs/EntityManager.spec.js +56 -6
- package/src/engine/ecs/animation/Animation.spec.js +22 -0
- package/src/engine/ecs/animation/AnimationSerializationAdapter.js +2 -5
- package/src/engine/ecs/attachment/Attachment.js +24 -25
- package/src/engine/ecs/attachment/AttachmentBinding.js +27 -30
- package/src/engine/ecs/attachment/AttachmentSystem.js +21 -24
- package/src/engine/ecs/attachment/BoneAttachmentBinding.js +6 -9
- package/src/engine/ecs/attachment/TransformAttachmentBinding.js +0 -3
- package/src/engine/ecs/components/CharacterController.js +24 -18
- package/src/engine/ecs/components/Motion.js +0 -27
- package/src/engine/ecs/components/MotionSerializationAdapter.js +26 -0
- package/src/engine/ecs/components/PropertySet.js +0 -29
- package/src/engine/ecs/components/PropertySetSerializationAdapter.js +29 -0
- package/src/engine/ecs/components/SerializationMetadata.js +0 -28
- package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.js +26 -0
- package/src/engine/ecs/components/Steering.js +0 -35
- package/src/engine/ecs/components/SteeringSerializationAdapter.js +34 -0
- package/src/engine/ecs/components/Tag.js +6 -102
- package/src/engine/ecs/components/TagSerializationAdapter.js +44 -0
- package/src/engine/ecs/components/TagSerializationUpgrader_0_1.js +18 -0
- package/src/engine/ecs/components/Timer.js +1 -1
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +4 -3
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleCooldownDescription.js +10 -14
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +31 -39
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.js +1 -1
- package/src/engine/ecs/dynamic_actions/{DynamicRuleDescriptionTable.spec.js → rules/DynamicRuleDescriptionTable.spec.js} +12 -12
- package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +2 -5
- package/src/engine/ecs/fow/FogOfWarRevealer.js +2 -3
- package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.js +2 -5
- package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +5 -8
- package/src/engine/ecs/gui/GUIElementSerializationAdapter.js +2 -5
- package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.js +3 -6
- package/src/engine/ecs/gui/position/ViewportPosition.js +2 -5
- package/src/engine/ecs/ik/IKConstraint.js +95 -0
- package/src/engine/ecs/ik/IKMath.js +6 -1
- package/src/engine/ecs/ik/IKProblem.js +17 -17
- package/src/engine/ecs/ik/InverseKinematics.js +14 -174
- package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js +72 -0
- package/src/engine/ecs/ik/InverseKinematicsSystem.js +24 -26
- package/src/engine/ecs/speaker/Voice.js +5 -8
- package/src/engine/ecs/speaker/VoiceSystem.js +15 -19
- package/src/engine/ecs/speaker/lines/LineDescription.js +20 -25
- package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +15 -19
- package/src/engine/ecs/storage/BinaryBufferSerializer.js +3 -3
- package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +7 -0
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
- package/src/engine/ecs/storage/binary/object/ObjectBasedClassSerializationAdapter.js +6 -9
- package/src/engine/ecs/systems/TagSystem.js +1 -6
- package/src/engine/ecs/team/TeamSerializationAdapter.js +2 -5
- package/src/engine/ecs/terrain/ecs/Terrain.spec.js +5 -0
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +23 -21
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +2 -5
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +2 -2
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -40
- package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.js +7 -10
- package/src/engine/ecs/tooltip/TooltipComponent.spec.js +47 -0
- package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.js +2 -5
- package/src/engine/ecs/transform/Transform.spec.js +52 -0
- package/src/engine/ecs/transform/TransformSerializationAdapter.js +2 -5
- package/src/engine/ecs/transform-attachment/TransformAttachment.js +18 -19
- package/src/engine/graphics/ecs/animation/AnimationController.js +20 -129
- package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.js +27 -0
- package/src/engine/graphics/ecs/animation/AnimationRule.js +79 -0
- package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.js +9 -11
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.js +3 -5
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.js +2 -6
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.js +3 -15
- package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +2 -4
- package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +1 -1
- package/src/engine/graphics/ecs/light/LightSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/mesh/skeleton/BoneMapping.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +3 -0
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +14 -0
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.js +21 -9
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.spec.js +79 -0
- package/src/engine/graphics/ecs/water/WaterSerializationAdapter.js +2 -5
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
- package/src/engine/graphics/material/manager/MaterialManager.js +1 -1
- package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
- package/src/engine/graphics/particles/node-based/codegen/CodeContext.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +2 -5
- package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.js +2 -5
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +1 -1
- package/src/engine/graphics/render/visibility/IncrementalDeltaSet.spec.js +7 -6
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +1 -1
- package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.js +2 -5
- package/src/engine/grid/grid2transform/GridPosition2Transform.js +11 -13
- package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +3 -5
- package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.js +2 -5
- package/src/engine/grid/position/GridPositionSerializationAdapter.js +2 -5
- package/src/engine/grid/transform2grid/Transform2GridPosition.js +10 -13
- package/src/engine/input/devices/KeyboardDevice.js +5 -2
- package/src/engine/input/devices/KeyboardDevice.spec.js +12 -0
- package/src/engine/input/devices/PointerDevice.js +5 -1
- package/src/engine/input/ecs/components/Input.js +37 -11
- package/src/engine/input/ecs/ism/InputBinding.js +30 -12
- package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +7 -10
- package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +2 -5
- package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +2 -6
- package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.js +2 -5
- package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.js +2 -5
- package/src/engine/knowledge/database/StaticKnowledgeDatabase.js +12 -13
- package/src/engine/knowledge/database/StaticKnowledgeDatabase.spec.js +23 -0
- package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +2 -5
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +2 -5
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +25 -0
- package/src/engine/options/OptionAbstract.js +6 -5
- package/src/engine/options/OptionGroup.js +13 -25
- package/src/engine/options/OptionGroup.spec.js +61 -0
- package/src/engine/save/storage/InMemoryStorage.js +3 -2
- package/src/engine/simulation/Ticker.js +17 -20
- package/src/engine/sound/ecs/SoundController.js +2 -6
- package/src/engine/sound/ecs/SoundListener.js +3 -21
- package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.js +2 -6
- package/src/generation/GridTaskGroup.js +5 -9
- package/src/generation/filtering/numeric/CellFilterCache.js +12 -16
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +31 -32
- package/src/generation/filtering/numeric/complex/CellFilterLookupTable.js +6 -9
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +7 -10
- package/src/generation/filtering/numeric/complex/CellFilterSobel.js +6 -9
- package/src/generation/filtering/numeric/math/CellFilterMembershipGeneralizedBell.js +18 -21
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +24 -25
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +1 -1
- package/src/generation/grid/GridData.js +23 -22
- package/src/generation/grid/GridData.spec.js +41 -0
- package/src/generation/grid/GridTaskGenerator.js +7 -8
- package/src/generation/grid/layers/GridDataLayer.js +23 -25
- package/src/generation/markers/GridActionRuleSet.js +20 -22
- package/src/generation/markers/GridCellActionPlaceMarker.js +40 -43
- package/src/generation/markers/GridCellActionPlaceMarkerGroup.js +7 -9
- package/src/generation/markers/MarkerNode.js +44 -44
- package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +15 -18
- package/src/generation/markers/actions/MarkerNodeActionSequence.js +6 -9
- package/src/generation/markers/actions/MarkerNodeProcessingRuleSet.js +5 -7
- package/src/generation/markers/actions/MarkerProcessingRule.js +25 -26
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +12 -15
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.js +2 -5
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorSequence.js +6 -9
- package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.js +8 -11
- package/src/generation/markers/actions/probability/MarkerNodeActionWeightedElement.js +13 -13
- package/src/generation/markers/actions/util/GridCellActionDebugBreak.js +5 -8
- package/src/generation/markers/actions/util/GridCellActionLogToConsole.js +1 -4
- package/src/generation/markers/emitter/MarkerNodeConsumerBuffer.js +10 -13
- package/src/generation/markers/emitter/MarkerNodeEmitterFromAction.js +5 -9
- package/src/generation/markers/emitter/MarkerNodeEmitterGridCellAction.js +12 -15
- package/src/generation/markers/emitter/MarkerNodeEmitterGroup.js +5 -8
- package/src/generation/markers/emitter/MarkerNodeEmitterPredicated.js +18 -21
- package/src/generation/markers/matcher/MarkerNodeMatcher.js +2 -1
- package/src/generation/markers/matcher/MarkerNodeMatcherBinary.js +12 -13
- package/src/generation/markers/matcher/MarkerNodeMatcherContainsTag.js +7 -9
- package/src/generation/markers/matcher/MarkerNodeMatcherNot.js +7 -9
- package/src/generation/markers/predicate/GridDataNodePredicateBinary.js +10 -14
- package/src/generation/markers/predicate/GridDataNodePredicateNot.js +9 -11
- package/src/generation/markers/predicate/GridDataNodePredicateOverlaps.js +6 -9
- package/src/generation/markers/transform/MarkerNodeTransformRotateRandom.js +2 -6
- package/src/generation/markers/transform/MarkerNodeTransformerAddPositionYFromFilter.js +6 -9
- package/src/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -4
- package/src/generation/markers/transform/MarkerNodeTransformerRecordProperty.js +12 -15
- package/src/generation/markers/transform/MarkerNodeTransformerRecordPropertyClosure.js +14 -17
- package/src/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +21 -23
- package/src/generation/markers/transform/MarkerNodeTransformerRemoveTag.js +1 -4
- package/src/generation/markers/transform/MarkerNodeTransformerSequence.js +6 -9
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.js +13 -17
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.js +12 -16
- package/src/generation/placement/GridCellActionTransformNearbyMarkers.js +26 -29
- package/src/generation/placement/GridCellPlacementRule.js +30 -32
- package/src/generation/placement/action/GridCellActionPlaceTags.js +26 -28
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +16 -20
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +13 -16
- package/src/generation/placement/action/random/weighted/WeightedGridCellAction.js +11 -14
- package/src/generation/placement/action/util/CellMatcherWithinAABB.js +2 -6
- package/src/generation/placement/action/util/GridCellActionSequence.js +7 -9
- package/src/generation/placement/action/util/GridCellDisplacedAction.js +9 -12
- package/src/generation/rules/CellMatcherFromFilter.js +6 -9
- package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -9
- package/src/generation/rules/GridLayerCellMatcher.js +11 -14
- package/src/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js +11 -14
- package/src/generation/rules/cell/CellMatcherGridPattern.js +6 -8
- package/src/generation/rules/cell/GridPatternMatcherCell.js +11 -12
- package/src/generation/rules/logic/CellMatcherBinary.js +10 -14
- package/src/generation/rules/logic/CellMatcherDecorator.js +5 -8
- package/src/generation/theme/AreaMask.js +15 -17
- package/src/generation/theme/AreaTheme.js +7 -8
- package/src/generation/theme/TerrainLayerDescription.js +10 -12
- package/src/generation/theme/TerrainLayerRule.js +11 -13
- package/src/generation/theme/TerrainTheme.js +6 -7
- package/src/generation/theme/Theme.js +15 -17
- package/src/generation/theme/ThemeEngine.js +17 -19
- package/src/view/string_tag_to_css_class_name.js +2 -2
- package/src/view/tooltip/gml/TooltipParser.js +2 -2
- package/src/core/cache/PersistentCacheAdapter.js +0 -378
- package/src/core/collection/LazyStream.js +0 -23
- package/src/core/collection/LazyStream.spec.js +0 -13
- package/src/core/collection/heap/BinaryHeap.js +0 -153
- package/src/core/primitives/strings/StringUtils.js +0 -105
- package/src/core/primitives/strings/StringUtils.spec.js +0 -42
- package/src/engine/ecs/components/GeometryBVH.js +0 -44
- package/src/engine/ecs/components/MonsterAI.js +0 -15
- package/src/engine/ecs/systems/GeometryBVHSystem.js +0 -36
- package/src/generation/markers/MarkerRelation.js +0 -13
- /package/src/core/collection/{HashMap.d.ts → map/HashMap.d.ts} +0 -0
- /package/src/core/collection/{HashSet.d.ts → set/HashSet.d.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import View from "../../../src/view/View.js";
|
|
2
2
|
import { PortDirection } from "../../../src/core/model/node-graph/node/PortDirection.js";
|
|
3
|
-
import { camelToKebab } from "../../../src/core/primitives/strings/StringUtils.js";
|
|
4
3
|
import LabelView from "../../../src/view/common/LabelView.js";
|
|
5
4
|
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
6
5
|
import { Color } from "../../../src/core/color/Color.js";
|
|
7
6
|
import { objectKeyByValue } from "../../../src/core/model/object/objectKeyByValue.js";
|
|
7
|
+
import { string_format_camel_to_kebab } from "../../../src/core/primitives/strings/string_format_camel_to_kebab.js";
|
|
8
8
|
|
|
9
9
|
const DEFAULT_TYPE_COLOR = new Color(1, 1, 1);
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ export class PortView extends View {
|
|
|
35
35
|
|
|
36
36
|
this.addClass(`direction-${objectKeyByValue(PortDirection, port.direction).toLocaleLowerCase()}`);
|
|
37
37
|
|
|
38
|
-
this.addClass(`data-type-${
|
|
38
|
+
this.addClass(`data-type-${string_format_camel_to_kebab(port.dataType.name)}`);
|
|
39
39
|
|
|
40
40
|
//add port name label
|
|
41
41
|
const vName = new LabelView(port.name, {
|
package/package.json
CHANGED
package/src/core/__module.js
CHANGED
package/src/core/cache/Cache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
-
import { HashMap } from "../collection/HashMap.js";
|
|
2
|
+
import { HashMap } from "../collection/map/HashMap.js";
|
|
3
3
|
import Signal from "../events/signal/Signal.js";
|
|
4
4
|
import { returnOne, returnZero, strictEquals } from "../function/Functions.js";
|
|
5
5
|
import { CacheElement } from "./CacheElement.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
import { Cache } from "./Cache.js";
|
|
4
|
+
import { current_time_in_seconds } from "../time/current_time_in_seconds.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @template R
|
|
@@ -18,13 +19,16 @@ class Record {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/**
|
|
23
|
+
* In seconds
|
|
24
|
+
* @readonly
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_TIME_TO_LIVE = 300; // 5 Minutes
|
|
26
28
|
|
|
27
29
|
/**
|
|
30
|
+
* Asynchronous cache capable of resolving its own values by keys
|
|
31
|
+
* Modelled on Guava's LoadingCache concept
|
|
28
32
|
* @template K,V
|
|
29
33
|
*/
|
|
30
34
|
export class LoadingCache {
|
|
@@ -33,6 +37,7 @@ export class LoadingCache {
|
|
|
33
37
|
*/
|
|
34
38
|
#internal
|
|
35
39
|
/**
|
|
40
|
+
* Time until records are marked as invalid, invalid records are not served back and trigger re-loading of the value
|
|
36
41
|
* In seconds
|
|
37
42
|
* @type {number}
|
|
38
43
|
*/
|
|
@@ -5,23 +5,20 @@ import Signal from "../events/signal/Signal.js";
|
|
|
5
5
|
* @class
|
|
6
6
|
*/
|
|
7
7
|
export class Stack {
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
|
-
* @
|
|
10
|
+
* @private
|
|
11
|
+
* @type {T[]}
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @private
|
|
15
|
-
* @type {T[]}
|
|
16
|
-
*/
|
|
17
|
-
this.data = [];
|
|
18
|
-
|
|
19
|
-
this.on = {
|
|
20
|
-
removed: new Signal(),
|
|
21
|
-
added: new Signal()
|
|
22
|
-
};
|
|
13
|
+
data = [];
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @readonly
|
|
17
|
+
*/
|
|
18
|
+
on = {
|
|
19
|
+
removed: new Signal(),
|
|
20
|
+
added: new Signal()
|
|
21
|
+
};
|
|
25
22
|
|
|
26
23
|
/**
|
|
27
24
|
* @returns {T[]}
|
|
@@ -11,12 +11,15 @@ export function array_contains_duplicates(
|
|
|
11
11
|
end_index = source.length - 1
|
|
12
12
|
) {
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// going to n-1, as we check all elements forward from the current
|
|
15
|
+
const last = end_index - 1;
|
|
16
|
+
|
|
17
|
+
for (let k = start_index; k <= last; k++) {
|
|
15
18
|
|
|
16
19
|
const element = source[k];
|
|
17
20
|
|
|
18
21
|
// look for future occurrences of the same element
|
|
19
|
-
if (source.indexOf(element, k + 1)
|
|
22
|
+
if (source.indexOf(element, k + 1) !== -1) {
|
|
20
23
|
return true;
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { array_contains_duplicates } from "./array_contains_duplicates.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
expect(array_contains_duplicates([])).toBe(false);
|
|
5
|
+
|
|
6
|
+
expect(array_contains_duplicates([1])).toBe(false);
|
|
7
|
+
|
|
8
|
+
expect(array_contains_duplicates([1, 2, 3])).toBe(false);
|
|
9
|
+
|
|
10
|
+
expect(array_contains_duplicates([1, 1])).toBe(true);
|
|
11
|
+
expect(array_contains_duplicates([0, 1, 1])).toBe(true);
|
|
12
|
+
expect(array_contains_duplicates([1, 0, 1])).toBe(true);
|
|
13
|
+
expect(array_contains_duplicates([1, 1, 0])).toBe(true);
|
|
14
|
+
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { array_copy } from "./array_copy.js";
|
|
2
|
+
import { array_shrink_to_size } from "./array_shrink_to_size.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @template T
|
|
3
6
|
* @param {T[]} source
|
|
@@ -5,17 +8,9 @@
|
|
|
5
8
|
*/
|
|
6
9
|
export function array_copy_entire(source, target) {
|
|
7
10
|
|
|
8
|
-
const
|
|
9
|
-
for (let i = 0; i < n; i++) {
|
|
10
|
-
const v = source[i];
|
|
11
|
-
|
|
12
|
-
target[i] = v;
|
|
13
|
-
}
|
|
14
|
-
|
|
11
|
+
const source_length = source.length;
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
array_copy(source, 0, target, 0, source_length);
|
|
14
|
+
array_shrink_to_size(target, source_length);
|
|
17
15
|
|
|
18
|
-
if (n > tL) {
|
|
19
|
-
target.splice(n, tL - n);
|
|
20
|
-
}
|
|
21
16
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} array
|
|
@@ -6,6 +8,9 @@
|
|
|
6
8
|
* @param {number} max_index
|
|
7
9
|
*/
|
|
8
10
|
export function array_get_index_in_range(array, needle, min_index, max_index) {
|
|
11
|
+
assert.lessThanOrEqual(max_index, array.length - 1, 'max_length must is too large');
|
|
12
|
+
assert.isNonNegativeInteger(min_index, 'min_index');
|
|
13
|
+
|
|
9
14
|
for (let i = min_index; i <= max_index; i++) {
|
|
10
15
|
if (array[i] === needle) {
|
|
11
16
|
return i;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { array_get_index_in_range } from "./array_get_index_in_range.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
|
|
5
|
+
expect(array_get_index_in_range([], 1, 0, -1)).toBe(-1);
|
|
6
|
+
expect(array_get_index_in_range([1], 1, 0, 0)).toBe(0);
|
|
7
|
+
|
|
8
|
+
expect(array_get_index_in_range([3, 1], 1, 0, 1)).toBe(1);
|
|
9
|
+
expect(array_get_index_in_range([3, 1], 1, 0, 0)).toBe(-1);
|
|
10
|
+
expect(array_get_index_in_range([3, 1], 1, 1, 1)).toBe(1);
|
|
11
|
+
|
|
12
|
+
expect(array_get_index_in_range([1, 3], 1, 0, 1)).toBe(0);
|
|
13
|
+
expect(array_get_index_in_range([1, 3], 1, 1, 1)).toBe(-1);
|
|
14
|
+
expect(array_get_index_in_range([1, 3], 1, 0, 0)).toBe(0);
|
|
15
|
+
|
|
16
|
+
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { array_remove_first } from "./array_remove_first.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
4
|
+
* @deprecated
|
|
2
5
|
* @template T
|
|
3
6
|
* @param {T[]} array
|
|
4
7
|
* @param {number} start_index
|
|
@@ -7,13 +10,7 @@
|
|
|
7
10
|
* @return {boolean}
|
|
8
11
|
*/
|
|
9
12
|
export function array_remove_element(array, start_index, end_index, element) {
|
|
10
|
-
|
|
11
|
-
if (array[i] === element) {
|
|
12
|
-
array.splice(i, 1);
|
|
13
|
-
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
13
|
+
console.warn('deprecated, use array_remove_first instead');
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
}
|
|
15
|
+
array_remove_first(array, element, start_index, end_index - start_index);
|
|
16
|
+
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Remove first occurrence of element from the array
|
|
2
3
|
* @template T
|
|
3
4
|
* @param {T[]} array
|
|
4
5
|
* @param {T} element
|
|
5
|
-
* @
|
|
6
|
+
* @param {number} [start_index]
|
|
7
|
+
* @param {number} [length]
|
|
8
|
+
* @return {boolean} true if element was removed, false if it was not found
|
|
6
9
|
*/
|
|
7
|
-
export function array_remove_first(array, element){
|
|
8
|
-
const i = array.indexOf(element);
|
|
10
|
+
export function array_remove_first(array, element, start_index = 0, length = array.length) {
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const end_index = start_index + length;
|
|
13
|
+
|
|
14
|
+
for (let i = start_index; i < end_index; i++) {
|
|
15
|
+
if (array[i] === element) {
|
|
16
|
+
array.splice(i, 1);
|
|
17
|
+
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
return false;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { array_remove_first } from "./array_remove_first.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
|
|
5
|
+
expect(array_remove_first([], 1)).toBe(false);
|
|
6
|
+
expect(array_remove_first([2], 1)).toBe(false);
|
|
7
|
+
expect(array_remove_first([2, 3], 1)).toBe(false);
|
|
8
|
+
|
|
9
|
+
let array = [1];
|
|
10
|
+
|
|
11
|
+
expect(array_remove_first(array, 1)).toBe(true);
|
|
12
|
+
|
|
13
|
+
expect(array).toEqual([]);
|
|
14
|
+
|
|
15
|
+
array = [1, 1];
|
|
16
|
+
|
|
17
|
+
expect(array_remove_first(array, 1)).toBe(true);
|
|
18
|
+
|
|
19
|
+
expect(array).toEqual([1]);
|
|
20
|
+
|
|
21
|
+
array = [2, 1];
|
|
22
|
+
|
|
23
|
+
expect(array_remove_first(array, 1)).toBe(true);
|
|
24
|
+
|
|
25
|
+
expect(array).toEqual([2]);
|
|
26
|
+
|
|
27
|
+
array = [1, 2];
|
|
28
|
+
|
|
29
|
+
expect(array_remove_first(array, 1)).toBe(true);
|
|
30
|
+
|
|
31
|
+
expect(array).toEqual([2]);
|
|
32
|
+
|
|
33
|
+
array = [1, 2, 1];
|
|
34
|
+
|
|
35
|
+
expect(array_remove_first(array, 1)).toBe(true);
|
|
36
|
+
|
|
37
|
+
expect(array).toEqual([2, 1]);
|
|
38
|
+
|
|
39
|
+
});
|
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
import { binarySearchHighIndex } from "./binarySearchHighIndex.js";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { number_compare_ascending } from "../../primitives/numbers/number_compare_ascending.js";
|
|
3
4
|
|
|
4
5
|
test('exact match single element 1', () => {
|
|
5
6
|
expect(
|
|
6
|
-
binarySearchHighIndex([1], 1,
|
|
7
|
+
binarySearchHighIndex([1], 1, number_compare_ascending, 0, 0)
|
|
7
8
|
).toBe(0);
|
|
8
9
|
});
|
|
9
10
|
|
|
10
11
|
test('exact match single element 0', () => {
|
|
11
12
|
expect(
|
|
12
|
-
binarySearchHighIndex([0], 0,
|
|
13
|
+
binarySearchHighIndex([0], 0, number_compare_ascending, 0, 0)
|
|
13
14
|
).toBe(0);
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
test('exact match single element -1', () => {
|
|
17
18
|
expect(
|
|
18
|
-
binarySearchHighIndex([-1], -1,
|
|
19
|
+
binarySearchHighIndex([-1], -1, number_compare_ascending, 0, 0)
|
|
19
20
|
).toBe(0);
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
test('0 -> 0,0', () => {
|
|
23
24
|
expect(
|
|
24
|
-
binarySearchHighIndex([0, 0], 0,
|
|
25
|
+
binarySearchHighIndex([0, 0], 0, number_compare_ascending, 0, 1)
|
|
25
26
|
).toBe(0);
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
test('0 -> 0,1', () => {
|
|
29
30
|
expect(
|
|
30
|
-
binarySearchHighIndex([0, 1], 0,
|
|
31
|
+
binarySearchHighIndex([0, 1], 0, number_compare_ascending, 0, 1)
|
|
31
32
|
).toBe(0);
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
test('1 -> 1,1', () => {
|
|
35
36
|
expect(
|
|
36
|
-
binarySearchHighIndex([1, 1], 1,
|
|
37
|
+
binarySearchHighIndex([1, 1], 1, number_compare_ascending, 0, 1)
|
|
37
38
|
).toBe(0);
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
test('0 -> 1,2', () => {
|
|
41
42
|
expect(
|
|
42
|
-
binarySearchHighIndex([1, 2], 0,
|
|
43
|
+
binarySearchHighIndex([1, 2], 0, number_compare_ascending, 0, 1)
|
|
43
44
|
).toBe(0);
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
test('1.5 -> 1,2', () => {
|
|
47
48
|
expect(
|
|
48
|
-
binarySearchHighIndex([1, 2], 1.5,
|
|
49
|
+
binarySearchHighIndex([1, 2], 1.5, number_compare_ascending, 0, 1)
|
|
49
50
|
).toBe(1);
|
|
50
51
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { randomizeArrayElementOrder } from "./randomizeArrayElementOrder.js";
|
|
2
|
+
|
|
3
|
+
test("sanity", () => {
|
|
4
|
+
|
|
5
|
+
const random = () => 0;
|
|
6
|
+
|
|
7
|
+
const a = [];
|
|
8
|
+
|
|
9
|
+
randomizeArrayElementOrder(random, a);
|
|
10
|
+
|
|
11
|
+
expect(a).toEqual([]);
|
|
12
|
+
|
|
13
|
+
const b = [1];
|
|
14
|
+
|
|
15
|
+
randomizeArrayElementOrder(random, b);
|
|
16
|
+
|
|
17
|
+
expect(b).toEqual([1]);
|
|
18
|
+
|
|
19
|
+
const c = [1, 2, 3];
|
|
20
|
+
|
|
21
|
+
randomizeArrayElementOrder(random, c);
|
|
22
|
+
|
|
23
|
+
expect(c.length).toBe(3);
|
|
24
|
+
expect(c).toContain(1);
|
|
25
|
+
expect(c).toContain(2);
|
|
26
|
+
expect(c).toContain(3);
|
|
27
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Uint32Heap } from "./Uint32Heap.js";
|
|
2
|
+
import { seededRandom } from "../../math/random/seededRandom.js";
|
|
2
3
|
|
|
3
4
|
test('initial capacity setting via constructor', () => {
|
|
4
5
|
const heap = new Uint32Heap(3);
|
|
@@ -57,3 +58,102 @@ test('insert 5 out of order, retrieve in order', () => {
|
|
|
57
58
|
expect(heap.pop_min()).toBe(3);
|
|
58
59
|
expect(heap.pop_min()).toBe(5);
|
|
59
60
|
});
|
|
61
|
+
|
|
62
|
+
test("remove", () => {
|
|
63
|
+
|
|
64
|
+
const heap = new Uint32Heap();
|
|
65
|
+
|
|
66
|
+
expect(heap.remove(7)).toBe(false);
|
|
67
|
+
|
|
68
|
+
heap.insert(7, 3);
|
|
69
|
+
|
|
70
|
+
expect(heap.remove(7)).toBe(true);
|
|
71
|
+
|
|
72
|
+
expect(heap.is_empty()).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("is_empty", () => {
|
|
76
|
+
|
|
77
|
+
const heap = new Uint32Heap();
|
|
78
|
+
|
|
79
|
+
expect(heap.is_empty()).toBe(true);
|
|
80
|
+
|
|
81
|
+
heap.insert(7, 0);
|
|
82
|
+
|
|
83
|
+
expect(heap.is_empty()).toBe(false);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("update_score", () => {
|
|
87
|
+
|
|
88
|
+
const heap = new Uint32Heap();
|
|
89
|
+
|
|
90
|
+
heap.insert(1, 3);
|
|
91
|
+
heap.insert(7, 11);
|
|
92
|
+
|
|
93
|
+
heap.update_score(7, -1);
|
|
94
|
+
|
|
95
|
+
expect(heap.pop_min()).toEqual(7);
|
|
96
|
+
expect(heap.pop_min()).toEqual(1);
|
|
97
|
+
|
|
98
|
+
// expect request to a missing element to throw
|
|
99
|
+
expect(() => heap.update_score(7, 0)).toThrow();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("get_score", () => {
|
|
103
|
+
|
|
104
|
+
const heap = new Uint32Heap();
|
|
105
|
+
|
|
106
|
+
expect(heap.get_score(7)).toBeNaN();
|
|
107
|
+
|
|
108
|
+
heap.insert(7, 31);
|
|
109
|
+
|
|
110
|
+
expect(heap.get_score(7)).toBe(31);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("insert_or_update", () => {
|
|
114
|
+
|
|
115
|
+
const heap = new Uint32Heap();
|
|
116
|
+
|
|
117
|
+
heap.insert_or_update(7, 1);
|
|
118
|
+
|
|
119
|
+
expect(heap.size).toBe(1);
|
|
120
|
+
expect(heap.get_score(7)).toBe(1);
|
|
121
|
+
|
|
122
|
+
heap.insert_or_update(7, 17);
|
|
123
|
+
|
|
124
|
+
expect(heap.size).toBe(1);
|
|
125
|
+
expect(heap.get_score(7)).toBe(17);
|
|
126
|
+
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
test.skip("performance 1,000,000 random element fill / drain", () => {
|
|
131
|
+
|
|
132
|
+
const random = seededRandom(7);
|
|
133
|
+
|
|
134
|
+
const COUNT = 1000000;
|
|
135
|
+
|
|
136
|
+
const random_values = new Float32Array(COUNT);
|
|
137
|
+
|
|
138
|
+
for (let i = 0; i < COUNT; i++) {
|
|
139
|
+
random_values[i] = random();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const heap = new Uint32Heap();
|
|
143
|
+
|
|
144
|
+
const t0 = performance.now();
|
|
145
|
+
for (let i = 0; i < COUNT; i++) {
|
|
146
|
+
heap.insert(i, random_values[i]);
|
|
147
|
+
}
|
|
148
|
+
const t1 = performance.now();
|
|
149
|
+
|
|
150
|
+
for (let i = 0; i < COUNT; i++) {
|
|
151
|
+
heap.pop_min();
|
|
152
|
+
}
|
|
153
|
+
const t2 = performance.now();
|
|
154
|
+
|
|
155
|
+
const fill_time = t1 - t0;
|
|
156
|
+
const drain_time = t2 - t1;
|
|
157
|
+
|
|
158
|
+
console.log(`Fill took ${fill_time}ms (${COUNT / (fill_time * 0.001)} elements per second), drain took ${drain_time}ms (${COUNT / (drain_time * 0.001)} elements per second)`);
|
|
159
|
+
});
|
|
@@ -87,10 +87,10 @@ export class Uint32Heap {
|
|
|
87
87
|
__capacity_grow() {
|
|
88
88
|
const old_capacity = this.__capacity;
|
|
89
89
|
|
|
90
|
-
const new_capacity = max2(
|
|
90
|
+
const new_capacity = Math.ceil(max2(
|
|
91
91
|
old_capacity * RESIZE_GROW_FACTOR,
|
|
92
92
|
old_capacity + RESIZE_GROW_MIN_COUNT
|
|
93
|
-
);
|
|
93
|
+
));
|
|
94
94
|
|
|
95
95
|
assert.greaterThan(new_capacity, old_capacity, 'invalid growth');
|
|
96
96
|
|
|
@@ -117,7 +117,10 @@ export class Uint32Heap {
|
|
|
117
117
|
compare(a, b) {
|
|
118
118
|
const float32 = this.__data_float32;
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
const a2 = a << 1; // same as a*2
|
|
121
|
+
const b2 = b << 1; // same as b*2
|
|
122
|
+
|
|
123
|
+
return float32[a2] < float32[b2];
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
/**
|
|
@@ -127,8 +130,9 @@ export class Uint32Heap {
|
|
|
127
130
|
* @param {number} j element index
|
|
128
131
|
*/
|
|
129
132
|
swap(i, j) {
|
|
130
|
-
|
|
131
|
-
const
|
|
133
|
+
// fast multiplication by 2
|
|
134
|
+
const i2 = i << 1; // same as i*2
|
|
135
|
+
const j2 = j << 1; // same as j*2
|
|
132
136
|
|
|
133
137
|
const uint32 = this.__data_uint32;
|
|
134
138
|
|
|
@@ -279,13 +283,17 @@ export class Uint32Heap {
|
|
|
279
283
|
/**
|
|
280
284
|
*
|
|
281
285
|
* @param {number} id
|
|
286
|
+
* @returns {boolean}
|
|
282
287
|
*/
|
|
283
288
|
remove(id) {
|
|
284
289
|
const i = this.find_index_by_id(id);
|
|
285
290
|
|
|
286
|
-
if (i
|
|
287
|
-
|
|
291
|
+
if (i === -1) {
|
|
292
|
+
return false;
|
|
288
293
|
}
|
|
294
|
+
|
|
295
|
+
this.__remove_by_index(i);
|
|
296
|
+
return true;
|
|
289
297
|
}
|
|
290
298
|
|
|
291
299
|
/**
|
|
@@ -381,6 +389,7 @@ export class Uint32Heap {
|
|
|
381
389
|
insert(id, score) {
|
|
382
390
|
assert.isNonNegativeInteger(id, 'value');
|
|
383
391
|
assert.lessThanOrEqual(id, UINT32_MAX - 1, 'must be less than or equal to (2^32 - 2)');
|
|
392
|
+
assert.isNumber(score, 'score');
|
|
384
393
|
|
|
385
394
|
if (this.__size >= this.__capacity) {
|
|
386
395
|
// need to re-allocate
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { assert } from "
|
|
2
|
-
import { invokeObjectEquals } from "
|
|
3
|
-
import { invokeObjectHash } from "
|
|
4
|
-
import { isPowerOfTwo } from "
|
|
5
|
-
import { ctz32 } from "
|
|
6
|
-
import { ceilPowerOfTwo } from "
|
|
7
|
-
import { UintArrayForCount } from "
|
|
8
|
-
import { array_copy } from "
|
|
9
|
-
import { min2 } from "
|
|
10
|
-
import { arraySwapElements } from "
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
3
|
+
import { invokeObjectHash } from "../../model/object/invokeObjectHash.js";
|
|
4
|
+
import { isPowerOfTwo } from "../../math/isPowerOrTwo.js";
|
|
5
|
+
import { ctz32 } from "../../binary/ctz32.js";
|
|
6
|
+
import { ceilPowerOfTwo } from "../../binary/operations/ceilPowerOfTwo.js";
|
|
7
|
+
import { UintArrayForCount } from "../array/typed/uint_array_for_count.js";
|
|
8
|
+
import { array_copy } from "../array/array_copy.js";
|
|
9
|
+
import { min2 } from "../../math/min2.js";
|
|
10
|
+
import { arraySwapElements } from "../array/arraySwapElements.js";
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
* Heavily inspired by ruby's "new" (circa 2016) hash table implementation
|