Instance Method


Adds the specified object to the tree.


- (void)addElement:(ElementType)element boundingRectMin:(vector_float2)boundingRectMin boundingRectMax:(vector_float2)boundingRectMax splitStrategy:(GKRTreeSplitStrategy)splitStrategy;



The object to be added to the tree.


The corner (with the lowest x- and y-coordinate values) of the bounding region occupied by the object.


The corner (with the highest x- and y-coordinate values) of the bounding region occupied by the object.


An option specifying the algorithm the tree should use to optimize its internal structure after adding the new element.


The bounding region of each object you add to the tree (specified with the boundingRectMin and boundingRectMax parameters) defines the location and size of that object in space. When you add an object, depending on the relation of that size and position to those of other objects in the tree, the tree may reorganize its internal structure so that later searches of the tree (with the elementsInBoundingRectMin:rectMax:) can perform more quickly.

The splitStrategy parameter controls how the tree reorganizes its internal structure when needed—you can use a different strategy each time you add an object. Which strategy provides the best performance depends on the organization of data in your app or game; for best results, experiment with different strategies and profile your app’s performance with each.

See Also

Adding and Removing Elements

- removeElement:boundingRectMin:boundingRectMax:

Removes the specified object from the tree.