Class ArraySortedSet<E>

  • Type Parameters:
    E -
    All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, java.util.SortedSet<E>

    public class ArraySortedSet<E>
    extends java.util.AbstractSet<E>
    implements java.util.SortedSet<E>, java.lang.Cloneable
    A thread-safe SortedSet implementation which uses an array as a backing store. Mutations to the backing store are guarded by a read-write lock. The purpose of this is to be a more garbage-collector friendly collection than ConcurrentSkipListSet at the cost of slightly more CPU cost at insert and deletion. When used as a backing store for AbstractQuantileEstimation, 5 million samples per second can be performed at the average invocation time of 3 microseconds.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArraySortedSet​(java.util.Comparator<? super E> comparator, int initialSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E e)  
      boolean addAll​(java.util.Collection<? extends E> c)  
      void clear()  
      ArraySortedSet<E> clone()  
      java.util.Comparator<? super E> comparator()  
      boolean contains​(java.lang.Object o)  
      boolean containsAll​(java.util.Collection<?> c)  
      boolean equals​(java.lang.Object o)  
      E first()  
      E floor​(E v)  
      void forEach​(java.util.function.Consumer<? super E> action)  
      int hashCode()  
      java.util.SortedSet<E> headSet​(E toElement)  
      boolean isEmpty()  
      java.util.Iterator<E> iterator()  
      E last()  
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      int size()  
      java.util.Spliterator<E> spliterator()  
      java.util.SortedSet<E> subSet​(E fromElement, E toElement)  
      java.util.SortedSet<E> tailSet​(E fromElement)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      • Methods inherited from class java.util.AbstractCollection

        toString
      • Methods inherited from class java.lang.Object

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

        parallelStream, removeIf, stream, toArray
    • Constructor Detail

      • ArraySortedSet

        public ArraySortedSet​(java.util.Comparator<? super E> comparator,
                              int initialSize)
    • Method Detail

      • clone

        public ArraySortedSet<E> clone()
        Overrides:
        clone in class java.lang.Object
      • iterator

        @Nonnull
        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
        Specified by:
        iterator in class java.util.AbstractCollection<E>
      • forEach

        public void forEach​(java.util.function.Consumer<? super E> action)
        Specified by:
        forEach in interface java.lang.Iterable<E>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.Set<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.Set<E>
        Overrides:
        isEmpty in class java.util.AbstractCollection<E>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
      • toArray

        @Nonnull
        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.Set<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • toArray

        @Nonnull
        public <T> T[] toArray​(@Nonnull
                               T[] a)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.Set<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • add

        public boolean add​(E e)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.Set<E>
        Overrides:
        add in class java.util.AbstractCollection<E>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.Set<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
      • containsAll

        public boolean containsAll​(@Nonnull
                                   java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.Set<E>
        Overrides:
        containsAll in class java.util.AbstractCollection<E>
      • addAll

        public boolean addAll​(@Nonnull
                              java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.Set<E>
        Overrides:
        addAll in class java.util.AbstractCollection<E>
      • comparator

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

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

        @Nonnull
        public java.util.SortedSet<E> headSet​(E toElement)
        Specified by:
        headSet in interface java.util.SortedSet<E>
      • tailSet

        @Nonnull
        public java.util.SortedSet<E> tailSet​(E fromElement)
        Specified by:
        tailSet in interface java.util.SortedSet<E>
      • first

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

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

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

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.Set<E>
        Overrides:
        equals in class java.util.AbstractSet<E>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.Set<E>
        Overrides:
        hashCode in class java.util.AbstractSet<E>
      • removeAll

        public boolean removeAll​(@Nonnull
                                 java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.Set<E>
        Overrides:
        removeAll in class java.util.AbstractSet<E>
      • retainAll

        public boolean retainAll​(@Nonnull
                                 java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.Set<E>
        Overrides:
        retainAll in class java.util.AbstractCollection<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.Set<E>
        Overrides:
        clear in class java.util.AbstractCollection<E>
      • floor

        public E floor​(E v)