Class IntervalTree<C extends Comparable<? super C>,D extends Comparable<? super D>,I extends Interval<C,D>>

java.lang.Object
org.apache.cassandra.utils.IntervalTree<C,D,I>
All Implemented Interfaces:
Iterable<I>
Direct Known Subclasses:
SSTableIntervalTree

public class IntervalTree<C extends Comparable<? super C>,D extends Comparable<? super D>,I extends Interval<C,D>> extends Object implements Iterable<I>
  • Field Details

    • EXPENSIVE_CHECKS

      public static final boolean EXPENSIVE_CHECKS
    • EMPTY_ARRAY

      public static final Interval[] EMPTY_ARRAY
  • Constructor Details

    • IntervalTree

      protected IntervalTree(Collection<I> intervals)
    • IntervalTree

      protected IntervalTree(I[] minSortedIntervals, I[] maxSortedIntervals)
      This constructor will not modify minSortedIntervals and maxSortedIntervals, but it also won't make defensive copies and will keep the originals.
  • Method Details

    • create

      protected IntervalTree<C,D,I> create(I[] minOrder, I[] maxOrder)
    • build

      public static <C extends Comparable<? super C>, D extends Comparable<? super D>, I extends Interval<C, D>> IntervalTree<C,D,I> build(Collection<I> intervals)
    • emptyTree

      public static <C extends Comparable<? super C>, D extends Comparable<? super D>, I extends Interval<C, D>> IntervalTree<C,D,I> emptyTree()
    • intervalCount

      public int intervalCount()
    • isEmpty

      public boolean isEmpty()
    • max

      public C max()
    • min

      public C min()
    • search

      public List<D> search(Interval<C,D> searchInterval)
    • search

      public List<D> search(C point)
    • update

      public IntervalTree<C,D,I> update(I[] removals, I[] additions)
      The input arrays aren't defensively copied and will be sorted. The update method doesn't allow duplicates or elements to be removed to be missing and this differs from the constructor which does not duplicate checking at all. It made more sense for update to be stricter because it is tracking removals and additions explicitly instead of building a list from scratch and in the targeted use case of a list of SSTables there are no duplicates. At a given point in time an sstable represents exactly one interval (although it may switch via removal and addition as in early open).
    • iterator

      public Iterator<I> iterator()
      Specified by:
      iterator in interface Iterable<C extends Comparable<? super C>>
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object