Class SafeTreeSet<E>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.NavigableSet<E>, java.util.Set<E>, java.util.SortedSet<E>

    @GwtIncompatible
    public final class SafeTreeSet<E>
    extends java.lang.Object
    implements java.io.Serializable, java.util.NavigableSet<E>
    A wrapper around TreeSet that aggressively checks to see if elements are mutually comparable. This implementation passes the navigable set test suites.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SafeTreeSet()  
      SafeTreeSet​(java.util.Collection<? extends E> collection)  
      SafeTreeSet​(java.util.Comparator<? super E> comparator)  
      SafeTreeSet​(java.util.SortedSet<E> set)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E element)  
      boolean addAll​(java.util.Collection<? extends E> collection)  
      E ceiling​(E e)  
      void clear()  
      java.util.Comparator<? super E> comparator()  
      boolean contains​(java.lang.Object object)  
      boolean containsAll​(java.util.Collection<?> c)  
      java.util.Iterator<E> descendingIterator()  
      java.util.NavigableSet<E> descendingSet()  
      boolean equals​(java.lang.Object obj)  
      E first()  
      E floor​(E e)  
      int hashCode()  
      java.util.SortedSet<E> headSet​(E toElement)  
      java.util.NavigableSet<E> headSet​(E toElement, boolean inclusive)  
      E higher​(E e)  
      boolean isEmpty()  
      java.util.Iterator<E> iterator()  
      E last()  
      E lower​(E e)  
      E pollFirst()  
      E pollLast()  
      boolean remove​(java.lang.Object object)  
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      int size()  
      java.util.NavigableSet<E> subSet​(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)  
      java.util.SortedSet<E> subSet​(E fromElement, E toElement)  
      java.util.SortedSet<E> tailSet​(E fromElement)  
      java.util.NavigableSet<E> tailSet​(E fromElement, boolean inclusive)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, 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.SortedSet

        spliterator
    • Constructor Detail

      • SafeTreeSet

        public SafeTreeSet()
      • SafeTreeSet

        public SafeTreeSet​(java.util.Collection<? extends E> collection)
      • SafeTreeSet

        public SafeTreeSet​(java.util.Comparator<? super E> comparator)
      • SafeTreeSet

        public SafeTreeSet​(java.util.SortedSet<E> set)
    • Method Detail

      • add

        public boolean add​(E element)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.Set<E>
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> collection)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.Set<E>
      • ceiling

        public E ceiling​(E e)
        Specified by:
        ceiling in interface java.util.NavigableSet<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.Set<E>
      • comparator

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

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

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

        public java.util.Iterator<E> descendingIterator()
        Specified by:
        descendingIterator in interface java.util.NavigableSet<E>
      • descendingSet

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

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

        public E floor​(E e)
        Specified by:
        floor in interface java.util.NavigableSet<E>
      • headSet

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

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

        public E higher​(E e)
        Specified by:
        higher in interface java.util.NavigableSet<E>
      • isEmpty

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

        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.NavigableSet<E>
        Specified by:
        iterator in interface java.util.Set<E>
      • last

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

        public E lower​(E e)
        Specified by:
        lower in interface java.util.NavigableSet<E>
      • pollFirst

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

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

        public boolean remove​(java.lang.Object object)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.Set<E>
      • removeAll

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

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

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

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

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

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

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

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

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

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.Set<E>
        Overrides:
        equals in class java.lang.Object
      • 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.lang.Object
      • toString

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