Home

# Class goog.structs.QuadTree

Constructs a new quad tree.

Instance Method Summary
| `balance_(?goog.structs.QuadTree.Node node)` Attempts to balance a node. A node will need balancing if all its children are empty or it contains just one leaf.
| `clear()` Removes all items from the tree.
| `clone() ⇒ ?goog.structs.QuadTree` Clones the quad-tree and returns the new instance.
| `contains(number x, number y) ⇒ boolean` Returns true if the point at (x, y) exists in the tree.
| `find_(?goog.structs.QuadTree.Node node, number x, number y) ⇒ ?goog.structs.QuadTree.Node` Finds a leaf node with the same (x, y) coordinates as the target point, or null if no point exists.
| `forEach(function ((Object|null), (goog.math.Coordinate|null), (goog.structs.QuadTree|null)): ? fn, ?Object= opt_obj)` Traverses the tree and calls a function on each node.
| `get(number x, number y, <Any Type> opt_default) ⇒ <Any Type>` Gets the value of the point at (x, y) or null if the point is empty.
| `getCount() ⇒ number`
| `getKeys() ⇒ ?Array` Returns an array containing the coordinates of each point stored in the tree.
| `getQuadrantForPoint_(?goog.structs.QuadTree.Node parent, number x, number y) ⇒ ?goog.structs.QuadTree.Node` Returns the child quadrant within a node that contains the given (x, y) coordinate.
| `getRootNode() ⇒ ?goog.structs.QuadTree.Node` Returns a reference to the tree's root node. Callers shouldn't modify nodes, directly. This is a convenience for visualization and debugging purposes.
| `getValues() ⇒ ?Array.<(Object|null)>` Returns an array containing all values stored within the tree.
| `insert_(?goog.structs.QuadTree.Node parent, ?goog.structs.QuadTree.Point point) ⇒ boolean` Inserts a point into the tree, updating the tree's structure if necessary.
| `isEmpty() ⇒ boolean`
| `remove(number x, number y) ⇒ <Any Type>` Removes a point from (x, y) if it exists.
| `set(number x, number y, <Any Type> value)` Sets the value of an (x, y) point within the quad-tree.
| `setPointForNode_(?goog.structs.QuadTree.Node node, ?goog.structs.QuadTree.Point point)` Sets the point for a node, as long as the node is a leaf or empty.
| `split_(?goog.structs.QuadTree.Node node)` Converts a leaf node to a pointer node and reinserts the node's point into the correct child.
| `traverse_(?goog.structs.QuadTree.Node node, function ((goog.structs.QuadTree.Node|null)): ? fn)` Traverses the tree depth-first, with quadrants being traversed in clockwise order (NE, SE, SW, NW). The provided function will be called for each leaf node that is encountered.