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.
Count the number of entries contained within space
.
Count the number of entries contained within space
.
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.
Combine the results of a search(space) into a single result.
Combine the results of a search(space) into a single result.
Search for all entries given a search space, spatial checking function, and criteria function.
Search for all entries given a search space, spatial checking function, and criteria function.
This method abstracts search and searchIntersection, where the
check
function is either space.contains or space.intersects,
respectively.
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.
Transform each entry's value using the given f
, returning a new
node.
Transform each entry's value using the given f
, returning a new
node.
Find the closest entry to pt
that is within d0
.
Find the closest entry to pt
that is within d0
.
This method will either return Some((distance, entry)) or None.
Find the closest k
entries to pt
that are within d0
, and
add them to the given priority queue pq
.
Find the closest k
entries to pt
that are within d0
, and
add them to the given priority queue pq
.
This method returns the distance of the farthest entry that is still included.
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.
Search for all entries contained in the search space.
Search for all entries contained in the search space.
Points on the boundary of the search space will be included.
Search for all entries intersecting the search space.
Search for all entries intersecting the search space.
Points on the boundary of the search space will be included.
Return an iterator over the results of a search.
Return an iterator over the results of a search.
This produces the same elements as search(space, f).iterator(), without having to build an entire vector at once.