MCPcopy Create free account
hub / github.com/lodborg/interval-tree / query

Method query

src/main/java/com/lodborg/intervaltree/TreeNode.java:300–318  ·  view source on GitHub ↗

A helper function for the IntervalTree#query(Comparable) method. It searches recursively for all intervals stored in the subtree rooted at the current node, that intersect a target point. @param root The root of the currently traversed subtree. May be null. @param point The query po

(TreeNode<T> root, T point, Set<Interval<T>> res)

Source from the content-addressed store, hash-verified

298 * @return The set of all intervals from the current subtree, containing the query.
299 */
300 public static <T extends Comparable<? super T>> Set<Interval<T>> query(TreeNode<T> root, T point, Set<Interval<T>> res) {
301 if (root == null)
302 return res;
303 if (point.compareTo(root.midpoint) <= 0){
304 for (Interval<T> next: root.increasing){
305 if (next.isRightOf(point))
306 break;
307 res.add(next);
308 }
309 return TreeNode.query(root.left, point, res);
310 } else{
311 for (Interval<T> next: root.decreasing){
312 if (next.isLeftOf(point))
313 break;
314 res.add(next);
315 }
316 return TreeNode.query(root.right, point, res);
317 }
318 }
319
320
321 /**

Callers 2

queryMethod · 0.95
treeCheckMethod · 0.45

Calls 3

isRightOfMethod · 0.80
addMethod · 0.80
isLeftOfMethod · 0.80

Tested by 1

treeCheckMethod · 0.36