Class IntervalTree<V extends Interval>

java.lang.Object
net.buildtheearth.terraminusminus.util.interval.IntervalTree<V>

public class IntervalTree<V extends Interval> extends Object
Implementation of a segment tree along a single axis of a series of 2-dimensional line segments.
  • Field Details

    • LIST_CACHE

      protected static final io.netty.util.concurrent.FastThreadLocal<List<?>> LIST_CACHE
    • NODE_SPLIT_CAPACITY

      protected static final int NODE_SPLIT_CAPACITY
      The number of values that must be present in a node in order for it to become eligible for splitting.
    • root

      protected final IntervalTree.Node<V extends Interval> root
    • size

      protected final int size
  • Constructor Details

    • IntervalTree

      public IntervalTree(@NonNull @NonNull Iterable<V> values)
  • Method Details

    • createNodeArray

      protected static <V extends Interval> IntervalTree.Node<V>[] createNodeArray(int length)
    • getAllIntersecting

      public List<V> getAllIntersecting(double point)
      Gets a List containing every value that contains the given point.
      Parameters:
      point - the interval that values must contain
      Returns:
      the values
    • forEachIntersecting

      public void forEachIntersecting(double point, @NonNull @NonNull Consumer<V> callback)
      Runs the given function on every value that contains the given point.
      Parameters:
      point - the interval that values must contain
      callback - the callback function to run
    • forEach

      public void forEach(@NonNull @NonNull Consumer<V> callback)
      Runs the given function on every value in the tree.
      Parameters:
      callback - the callback function to run
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • size

      public int size()