T
- The data type stored in this RTreepublic abstract class AbstractRTree<T extends RNode> extends java.util.AbstractCollection<T> implements RTreeInterface<T>
RTreeInterface
interface to minimize the effort required to implement an RTree.
The programmer should generally provide a void (no argument) and collection
constructor, as per the recommendation in the Collection
interface
specification.
Methods which modify the RTree should increment modCount so the stream methods can detect concurrent modification.
Subclasses should consider implementing:
Modifier and Type | Class and Description |
---|---|
static class |
AbstractRTree.PairDebug<P,Q> |
Constructor and Description |
---|
AbstractRTree() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.Object obj) |
boolean |
containsAll(java.util.Collection<?> c) |
void |
forEach(java.util.function.Predicate<? super Mer> merFilter,
java.util.function.Consumer<? super T> action)
The specified action is applied to every node that touches the search mer.
|
boolean |
isEmpty() |
<Q extends RNode> |
join(RTreeInterface<Q> rtree1,
java.util.function.Predicate<? super Mer> merFilter)
Do a join of this RTree with rtree1.
|
java.util.stream.Stream<T> |
search(java.util.Comparator<? super RNode> compareFunc)
Search the tree (Mers) in the order specified by the comparator.
|
java.util.stream.Stream<T> |
search(java.util.function.ToDoubleFunction<? super RNode> sortMetric)
Search the tree of Mers in the order specified by the metric computed on the Mers of the tree.
|
java.util.stream.Stream<T> |
searchMer(java.util.function.Predicate<? super Mer> merFilter)
Return all the objects which satisfy the merFilter.
|
T |
searchNearest(java.util.Comparator<? super RNode> compareFunc)
Return the first data element as specified by the comparator.
|
T |
searchNearest(java.util.function.ToDoubleFunction<? super RNode> sortMetric)
Search the tree of Mers in the order specified by the metric computed on the Mers of the tree and return
the single smallest item.
|
add, addAll, clear, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, forEach, join, join, removeIf, removeIf, search, searchMer, searchNearest, size
public boolean isEmpty()
public java.util.stream.Stream<T> searchMer(java.util.function.Predicate<? super Mer> merFilter)
RTreeInterface
List<T> touches = tree.searchmer(x -> targetMer.interacts(x)).collect(Collectors.toList());
searchMer
in interface RTreeInterface<T extends RNode>
merFilter
- the search merpublic java.util.stream.Stream<T> search(java.util.Comparator<? super RNode> compareFunc)
RTreeInterface
To order the priority queue, compareFunc will be called multiple times per node visited. If your
comparison function is expensive, consider using RTreeInterface.search(ToDoubleFunction)
instead.
search
in interface RTreeInterface<T extends RNode>
compareFunc
- indicates which Mer or leaf is closer to the target. See note on distance metric in
the javadoc for this interface.public T searchNearest(java.util.Comparator<? super RNode> compareFunc)
RTreeInterface
To order the priority queue, compareFunc will be called multiple times per node visited. If your
comparison function is expensive, consider using RTreeInterface.searchNearest(ToDoubleFunction)
instead.
searchNearest
in interface RTreeInterface<T extends RNode>
compareFunc
- indicates which Mer or leaf is closest to the target. See note on distance metric
in the javadoc for this interface.public java.util.stream.Stream<T> search(java.util.function.ToDoubleFunction<? super RNode> sortMetric)
RTreeInterface
Distances of Double.POSITIVE_INFINITY will not be searched or returned. Data nodes of distance Double.NEGATIVE_INFINITY are returned immediately as they are found and may reduce the search effort.
search
in interface RTreeInterface<T extends RNode>
sortMetric
- indicates the "distance" to the target as a double value. See note on distance metric
in the javadoc for this interface.public T searchNearest(java.util.function.ToDoubleFunction<? super RNode> sortMetric)
RTreeInterface
Distances of Double.POSITIVE_INFINITY will not be searched or returned. A data node with distance Double.NEGATIVE_INFINITY will be returned immediately if found.
searchNearest
in interface RTreeInterface<T extends RNode>
sortMetric
- indicates the "distance" to the target as a double value. See note on distance metric
in the javadoc for this interface.public <Q extends RNode> java.util.stream.Stream<Pair<T,Q>> join(RTreeInterface<Q> rtree1, java.util.function.Predicate<? super Mer> merFilter)
RTreeInterface
join
in interface RTreeInterface<T extends RNode>
Q
- the type of the joined rtreertree1
- the tree to joinmerFilter
- restricts the area of the joinpublic boolean contains(java.lang.Object obj)
public boolean containsAll(java.util.Collection<?> c)
public void forEach(java.util.function.Predicate<? super Mer> merFilter, java.util.function.Consumer<? super T> action)
RTreeInterface
forEach
in interface RTreeInterface<T extends RNode>
merFilter
- selects the objects to be processed.action
- the action to apply objects of interest.