Class IntervalTree<C extends java.lang.Comparable<? super C>,​D extends java.lang.Comparable<? super D>,​I extends Interval<C,​D>>

  • All Implemented Interfaces:
    java.lang.Iterable<I>
    Direct Known Subclasses:
    SSTableIntervalTree

    public class IntervalTree<C extends java.lang.Comparable<? super C>,​D extends java.lang.Comparable<? super D>,​I extends Interval<C,​D>>
    extends java.lang.Object
    implements java.lang.Iterable<I>
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      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.
      protected IntervalTree​(java.util.Collection<I> intervals)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <C extends java.lang.Comparable<? super C>,​D extends java.lang.Comparable<? super D>,​I extends Interval<C,​D>>
      IntervalTree<C,​D,​I>
      build​(java.util.Collection<I> intervals)  
      protected IntervalTree<C,​D,​I> create​(I[] minOrder, I[] maxOrder)  
      static <C extends java.lang.Comparable<? super C>,​D extends java.lang.Comparable<? super D>,​I extends Interval<C,​D>>
      IntervalTree<C,​D,​I>
      emptyTree()  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      int intervalCount()  
      boolean isEmpty()  
      java.util.Iterator<I> iterator()  
      C max()  
      C min()  
      java.util.List<D> search​(C point)  
      java.util.List<D> search​(Interval<C,​D> searchInterval)  
      java.lang.String toString()  
      IntervalTree<C,​D,​I> update​(I[] removals, I[] additions)
      The input arrays aren't defensively copied and will be sorted.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • EXPENSIVE_CHECKS

        public static final boolean EXPENSIVE_CHECKS
      • EMPTY_ARRAY

        public static final Interval[] EMPTY_ARRAY
    • Constructor Detail

      • IntervalTree

        protected IntervalTree​(java.util.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 Detail

      • create

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

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

        public static <C extends java.lang.Comparable<? super C>,​D extends java.lang.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 java.util.List<D> search​(Interval<C,​D> searchInterval)
      • search

        public java.util.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 java.util.Iterator<I> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<C extends java.lang.Comparable<? super C>>
      • toString

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object