Interface: bitree

syngen.utility.bitree

Provides a binary tree interface for storing and querying objects in one-dimensional space.

Source:
See:
To Do:
  • Document private members

Methods

(static) create(optionsopt) → {syngen.utility.bitree}

Instantiates a new binary tree.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
dimension String <optional>
value

Key used to access items' values. Must be a member, not a method.

maxItems Number <optional>
12

Number of items before the tree branches. This value is passed to child nodes.

minValue Number <optional>
-syngen.const.maxSafeFloat

Lower bound of values for this node. Typically this is set programmatically.

range String <optional>
syngen.const.maxSafeFloat * 2

Range of values for this node. Typically this is set programmatically.

Source:
Returns:
Type
syngen.utility.bitree

(static) from(itemsopt, optionsopt) → {syngen.utility.bitree}

Instantiates a new binary tree with items and options.

Parameters:
Name Type Attributes Default Description
items Array.<Object> <optional>
[]
options Object <optional>
{}

See syngen.utility.bitree.create for a full reference.

Source:
Returns:
Type
syngen.utility.bitree

clear()

Clears all nodes and items.

Source:

destroy()

Prepares the instance for garbage collection.

Source:

find(query, radiusopt) → {Object|undefined}

Finds the closest item to query within radius. The query must contain a member set to the configured dimension. If query is contained within the tree, then the next closest item is returned. If no result is found, then undefined is returned.

Parameters:
Name Type Attributes Default Description
query Object
Properties
Name Type Description
{dimension} Number
radius Number <optional>
Infinity
Source:
Returns:
Type
Object | undefined

insert(item)

Inserts item into the tree.

Parameters:
Name Type Description
item Object
Source:

intersects(minValue, range) → {Boolean}

Returns whether this node intersects the line segment starting at minValue with length range.

Parameters:
Name Type Description
minValue Number
range Number
Source:
Returns:
Type
Boolean

remove(item)

Removes item from the tree, if it exists.

Parameters:
Name Type Description
item Object
Source:

retrieve(minValue, range) → {Array.<Object>}

Retrieves all items with values along the line segment starting at minValue with length range.

Parameters:
Name Type Description
minValue Number
range Number
Source:
Returns:
Type
Array.<Object>