Determine if entry is contained in the tree.
Determine if entry is contained in the tree.
This method depends upon reasonable equality for A. It can only match an Entry(pt, x) if entry.value == x.value.
Determine if we need to try contracting our bounding box based on the loss of 'geom'.
Determine if we need to try contracting our bounding box based on the loss of 'geom'. If so, use the by-name parameter 'regen' to recalculate. Since regen is by-name, it won't be evaluated unless we need it.
Put all the entries this node contains (directly or indirectly) into a vector.
Put all the entries this node contains (directly or indirectly) into a vector. Obviously this could be quite large in the case of a root node, so it should not be used for traversals.
Insert a new Entry into the tree.
Insert a new Entry into the tree.
Since this node is immutable, the method will return a replacement. There are two possible situations:
1. We can replace this node with a new node. This is the common case.
2. This node was already "full", so we can't just replace it with a single node. Instead, we will split this node into (presumably) two new nodes, and return a vector of them.
The reason we are using vector here is that it simplifies the implementation, and also because eventually we may support bulk insertion, where more than two nodes might be returned.
Returns an iterator over all the entires this node contains (directly or indirectly).
Returns an iterator over all the entires this node contains (directly or indirectly). Since nodes are immutable there is no concern over concurrent updates while using the iterator.
Method to pretty-print an r-tree.
Method to pretty-print an r-tree.
This method should only be called on small-ish trees! It will print one line for every branch, leaf, and entry, so for a tree with thousands of entries this will result in a very large string!
Remove this entry from the tree.
Remove this entry from the tree.
The implementations for Leaf and Branch are somewhat involved, so they are defined in each subclass.
The return value can be understood as follows:
1. None: the entry was not found in this node. This is the most common case.
2. Some((es, None)): the entry was found, and this node was removed (meaning after removal it had too few other children). The 'es' vector are entries that need to be readded to the RTree.
3. Some((es, Some(node))): the entry was found, and this node should be replaced by 'node'. Like above, the 'es' vector contains entries that should be readded.
Because adding entries may require rebalancing the tree, we defer the insertions until after the removal is complete and then readd them in RTree. While 'es' will usually be quite small, it's possible that in some cases it may be very large.
TODO: To avoid allocating large vectors, we could create a custom collection which could be pieced together out of vectors and singletons.
Performs a search for all entries in the search space.
Performs a search for all entries in the search space.
Points on the boundary of the search space will be included.