Class BTreeSet<V>

  • All Implemented Interfaces:
    java.lang.Iterable<V>, java.util.Collection<V>, java.util.List<V>, java.util.NavigableSet<V>, java.util.Set<V>, java.util.SortedSet<V>
    Direct Known Subclasses:
    BTreeSet.BTreeRange

    public class BTreeSet<V>
    extends java.lang.Object
    implements java.util.NavigableSet<V>, java.util.List<V>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Comparator<? super V> comparator  
      protected java.lang.Object[] tree  
    • Constructor Summary

      Constructors 
      Constructor Description
      BTreeSet​(java.lang.Object[] tree, java.util.Comparator<? super V> comparator)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, V element)  
      boolean add​(V v)  
      boolean addAll​(int index, java.util.Collection<? extends V> c)  
      boolean addAll​(java.util.Collection<? extends V> c)  
      static <V> BTreeSet.Builder<V> builder​(java.util.Comparator<? super V> comparator)  
      static <V> BTreeSet.Builder<V> builder​(java.util.Comparator<? super V> comparator, int initialCapacity)
      if you know the precise size of the resultant set use perfectBuilder instead.
      V ceiling​(V v)  
      void clear()  
      java.util.Comparator<? super V> comparator()  
      boolean contains​(java.lang.Object o)  
      boolean containsAll​(java.util.Collection<?> c)  
      static <V> BTreeSet<V> copy​(java.util.SortedSet<? extends V> copy, java.util.Comparator<? super V> comparator)  
      static <V> BTreeSet<V> copy​(java.util.SortedSet<? extends V> copy, java.util.Comparator<? super V> comparator, java.util.function.Function<V,​V> modifier)  
      BTreeSearchIterator<V,​V> descendingIterator()  
      BTreeSet<V> descendingSet()  
      static <V> BTreeSet<V> empty​(java.util.Comparator<? super V> comparator)  
      V first()  
      V floor​(V v)  
      V get​(int index)
      The converse of indexOf: provided an index between 0 and size, returns the i'th item, in set order.
      int hashCode()  
      java.util.SortedSet<V> headSet​(V toElement)  
      BTreeSet<V> headSet​(V toElement, boolean inclusive)  
      V higher​(V v)  
      int indexOf​(java.lang.Object item)
      The index of the item within the list, or its insertion point otherwise.
      boolean isEmpty()  
      BTreeSearchIterator<V,​V> iterator()  
      V last()  
      int lastIndexOf​(java.lang.Object o)  
      java.util.ListIterator<V> listIterator()  
      java.util.ListIterator<V> listIterator​(int index)  
      V lower​(V v)  
      static <V extends java.lang.Comparable<V>>
      BTreeSet<V>
      of​(java.util.Collection<V> sortedValues)  
      static <V> BTreeSet<V> of​(java.util.Comparator<? super V> comparator, V value)  
      static <V extends java.lang.Comparable<V>>
      BTreeSet<V>
      of​(V value)  
      V pollFirst()  
      V pollLast()  
      V remove​(int index)  
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      V set​(int index, V element)  
      int size()  
      protected BTreeSearchIterator<V,​V> slice​(BTree.Dir dir)  
      java.util.Spliterator<V> spliterator()  
      BTreeSet<V> subList​(int fromIndex, int toIndex)  
      BTreeSet<V> subSet​(V fromElement, boolean fromInclusive, V toElement, boolean toInclusive)  
      java.util.SortedSet<V> subSet​(V fromElement, V toElement)  
      java.util.SortedSet<V> tailSet​(V fromElement)  
      BTreeSet<V> tailSet​(V fromElement, boolean inclusive)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      <T> T[] toArray​(T[] a, int offset)  
      java.lang.Object[] tree()  
      static <V> BTreeSet<V> wrap​(java.lang.Object[] btree, java.util.Comparator<? super V> comparator)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        equals, replaceAll, sort
      • Methods inherited from interface java.util.Set

        equals
    • Field Detail

      • comparator

        protected final java.util.Comparator<? super V> comparator
      • tree

        protected final java.lang.Object[] tree
    • Constructor Detail

      • BTreeSet

        public BTreeSet​(java.lang.Object[] tree,
                        java.util.Comparator<? super V> comparator)
    • Method Detail

      • comparator

        public java.util.Comparator<? super V> comparator()
        Specified by:
        comparator in interface java.util.SortedSet<V>
      • tree

        public java.lang.Object[] tree()
      • indexOf

        public int indexOf​(java.lang.Object item)
        The index of the item within the list, or its insertion point otherwise. i.e. binarySearch semantics
        Specified by:
        indexOf in interface java.util.List<V>
      • get

        public V get​(int index)
        The converse of indexOf: provided an index between 0 and size, returns the i'th item, in set order.
        Specified by:
        get in interface java.util.List<V>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<V>
      • subList

        public BTreeSet<V> subList​(int fromIndex,
                                   int toIndex)
        Specified by:
        subList in interface java.util.List<V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<V>
        Specified by:
        size in interface java.util.List<V>
        Specified by:
        size in interface java.util.Set<V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<V>
        Specified by:
        isEmpty in interface java.util.List<V>
        Specified by:
        isEmpty in interface java.util.Set<V>
      • iterator

        public BTreeSearchIterator<V,​V> iterator()
        Specified by:
        iterator in interface java.util.Collection<V>
        Specified by:
        iterator in interface java.lang.Iterable<V>
        Specified by:
        iterator in interface java.util.List<V>
        Specified by:
        iterator in interface java.util.NavigableSet<V>
        Specified by:
        iterator in interface java.util.Set<V>
      • descendingIterator

        public BTreeSearchIterator<V,​V> descendingIterator()
        Specified by:
        descendingIterator in interface java.util.NavigableSet<V>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<V>
        Specified by:
        toArray in interface java.util.List<V>
        Specified by:
        toArray in interface java.util.Set<V>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<V>
        Specified by:
        toArray in interface java.util.List<V>
        Specified by:
        toArray in interface java.util.Set<V>
      • toArray

        public <T> T[] toArray​(T[] a,
                               int offset)
      • spliterator

        public java.util.Spliterator<V> spliterator()
        Specified by:
        spliterator in interface java.util.Collection<V>
        Specified by:
        spliterator in interface java.lang.Iterable<V>
        Specified by:
        spliterator in interface java.util.List<V>
        Specified by:
        spliterator in interface java.util.Set<V>
        Specified by:
        spliterator in interface java.util.SortedSet<V>
      • subSet

        public BTreeSet<V> subSet​(V fromElement,
                                  boolean fromInclusive,
                                  V toElement,
                                  boolean toInclusive)
        Specified by:
        subSet in interface java.util.NavigableSet<V>
      • headSet

        public BTreeSet<V> headSet​(V toElement,
                                   boolean inclusive)
        Specified by:
        headSet in interface java.util.NavigableSet<V>
      • tailSet

        public BTreeSet<V> tailSet​(V fromElement,
                                   boolean inclusive)
        Specified by:
        tailSet in interface java.util.NavigableSet<V>
      • subSet

        public java.util.SortedSet<V> subSet​(V fromElement,
                                             V toElement)
        Specified by:
        subSet in interface java.util.NavigableSet<V>
        Specified by:
        subSet in interface java.util.SortedSet<V>
      • headSet

        public java.util.SortedSet<V> headSet​(V toElement)
        Specified by:
        headSet in interface java.util.NavigableSet<V>
        Specified by:
        headSet in interface java.util.SortedSet<V>
      • tailSet

        public java.util.SortedSet<V> tailSet​(V fromElement)
        Specified by:
        tailSet in interface java.util.NavigableSet<V>
        Specified by:
        tailSet in interface java.util.SortedSet<V>
      • descendingSet

        public BTreeSet<V> descendingSet()
        Specified by:
        descendingSet in interface java.util.NavigableSet<V>
      • first

        public V first()
        Specified by:
        first in interface java.util.SortedSet<V>
      • last

        public V last()
        Specified by:
        last in interface java.util.SortedSet<V>
      • lower

        public V lower​(V v)
        Specified by:
        lower in interface java.util.NavigableSet<V>
      • floor

        public V floor​(V v)
        Specified by:
        floor in interface java.util.NavigableSet<V>
      • ceiling

        public V ceiling​(V v)
        Specified by:
        ceiling in interface java.util.NavigableSet<V>
      • higher

        public V higher​(V v)
        Specified by:
        higher in interface java.util.NavigableSet<V>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<V>
        Specified by:
        contains in interface java.util.List<V>
        Specified by:
        contains in interface java.util.Set<V>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<V>
        Specified by:
        containsAll in interface java.util.List<V>
        Specified by:
        containsAll in interface java.util.Set<V>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<V>
        Specified by:
        hashCode in interface java.util.List<V>
        Specified by:
        hashCode in interface java.util.Set<V>
        Overrides:
        hashCode in class java.lang.Object
      • addAll

        public boolean addAll​(java.util.Collection<? extends V> c)
        Specified by:
        addAll in interface java.util.Collection<V>
        Specified by:
        addAll in interface java.util.List<V>
        Specified by:
        addAll in interface java.util.Set<V>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends V> c)
        Specified by:
        addAll in interface java.util.List<V>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<V>
        Specified by:
        retainAll in interface java.util.List<V>
        Specified by:
        retainAll in interface java.util.Set<V>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<V>
        Specified by:
        removeAll in interface java.util.List<V>
        Specified by:
        removeAll in interface java.util.Set<V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<V>
        Specified by:
        clear in interface java.util.List<V>
        Specified by:
        clear in interface java.util.Set<V>
      • pollFirst

        public V pollFirst()
        Specified by:
        pollFirst in interface java.util.NavigableSet<V>
      • pollLast

        public V pollLast()
        Specified by:
        pollLast in interface java.util.NavigableSet<V>
      • add

        public boolean add​(V v)
        Specified by:
        add in interface java.util.Collection<V>
        Specified by:
        add in interface java.util.List<V>
        Specified by:
        add in interface java.util.Set<V>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<V>
        Specified by:
        remove in interface java.util.List<V>
        Specified by:
        remove in interface java.util.Set<V>
      • set

        public V set​(int index,
                     V element)
        Specified by:
        set in interface java.util.List<V>
      • add

        public void add​(int index,
                        V element)
        Specified by:
        add in interface java.util.List<V>
      • remove

        public V remove​(int index)
        Specified by:
        remove in interface java.util.List<V>
      • listIterator

        public java.util.ListIterator<V> listIterator()
        Specified by:
        listIterator in interface java.util.List<V>
      • listIterator

        public java.util.ListIterator<V> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<V>
      • builder

        public static <V> BTreeSet.Builder<V> builder​(java.util.Comparator<? super V> comparator)
      • builder

        public static <V> BTreeSet.Builder<V> builder​(java.util.Comparator<? super V> comparator,
                                                      int initialCapacity)
        if you know the precise size of the resultant set use perfectBuilder instead.
      • wrap

        public static <V> BTreeSet<V> wrap​(java.lang.Object[] btree,
                                           java.util.Comparator<? super V> comparator)
      • of

        public static <V extends java.lang.Comparable<V>> BTreeSet<V> of​(java.util.Collection<V> sortedValues)
      • of

        public static <V extends java.lang.Comparable<V>> BTreeSet<V> of​(V value)
      • empty

        public static <V> BTreeSet<V> empty​(java.util.Comparator<? super V> comparator)
      • of

        public static <V> BTreeSet<V> of​(java.util.Comparator<? super V> comparator,
                                         V value)
      • copy

        public static <V> BTreeSet<V> copy​(java.util.SortedSet<? extends V> copy,
                                           java.util.Comparator<? super V> comparator)
      • copy

        public static <V> BTreeSet<V> copy​(java.util.SortedSet<? extends V> copy,
                                           java.util.Comparator<? super V> comparator,
                                           java.util.function.Function<V,​V> modifier)