Class ImmutableTreeSet<T>

    • Field Detail

      • delegate

        private final T[] delegate
      • comparator

        private final java.util.Comparator<? super T> comparator
    • Constructor Detail

      • ImmutableTreeSet

        private ImmutableTreeSet​(T[] input,
                                 java.util.Comparator<? super T> inputComparator,
                                 boolean isSortedAndUnique)
    • Method Detail

      • newSetWith

        public static <T> ImmutableSortedSet<T> newSetWith​(java.util.Comparator<? super T> comparator,
                                                           T... elements)
      • newSet

        public static <T> ImmutableSortedSet<T> newSet​(java.util.SortedSet<? super T> set)
      • newSetFromIterable

        public static <T> ImmutableSortedSet<T> newSetFromIterable​(java.lang.Iterable<? extends T> iterable)
      • newSetFromIterable

        public static <T> ImmutableSortedSet<T> newSetFromIterable​(java.util.Comparator<? super T> comparator,
                                                                   java.lang.Iterable<? extends T> iterable)
      • size

        public int size()
        Description copied from interface: RichIterable
        Returns the number of items in this iterable.
        Specified by:
        size in interface java.util.Collection<T>
        Specified by:
        size in interface RichIterable<T>
        Specified by:
        size in interface java.util.Set<T>
      • writeReplace

        private java.lang.Object writeReplace()
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: SetIterable
        Follows the same general contract as Set.equals(Object).
        Specified by:
        equals in interface java.util.Collection<T>
        Specified by:
        equals in interface java.util.Set<T>
        Specified by:
        equals in interface SetIterable<T>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Description copied from interface: SetIterable
        Follows the same general contract as Set.hashCode().
        Specified by:
        hashCode in interface java.util.Collection<T>
        Specified by:
        hashCode in interface java.util.Set<T>
        Specified by:
        hashCode in interface SetIterable<T>
        Overrides:
        hashCode in class java.lang.Object
      • contains

        public boolean contains​(java.lang.Object object)
        Description copied from interface: RichIterable
        Returns true if the iterable has an element which responds true to element.equals(object).
        Specified by:
        contains in interface java.util.Collection<T>
        Specified by:
        contains in interface RichIterable<T>
        Specified by:
        contains in interface java.util.Set<T>
        Overrides:
        contains in class AbstractRichIterable<T>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface java.util.Set<T>
      • each

        public void each​(Procedure<? super T> procedure)
        Description copied from interface: RichIterable
        The procedure is executed for each element in the iterable.

        Example using a Java 8 lambda expression:

         people.each(person -> LOGGER.info(person.getName()));
         

        Example using an anonymous inner class:

         people.each(new Procedure<Person>()
         {
             public void value(Person person)
             {
                 LOGGER.info(person.getName());
             }
         });
         
        This method is a variant of InternalIterable.forEach(Procedure) that has a signature conflict with Iterable.forEach(java.util.function.Consumer).
        Specified by:
        each in interface RichIterable<T>
        See Also:
        InternalIterable.forEach(Procedure), Iterable.forEach(java.util.function.Consumer)
      • first

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

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

        public java.util.Comparator<? super T> comparator()
        Description copied from interface: SortedSetIterable
        Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
        Specified by:
        comparator in interface SortedIterable<T>
        Specified by:
        comparator in interface java.util.SortedSet<T>
        Specified by:
        comparator in interface SortedSetIterable<T>
      • compareTo

        public int compareTo​(SortedSetIterable<T> otherSet)
        Specified by:
        compareTo in interface java.lang.Comparable<T>
      • compare

        private int compare​(T o1,
                            T o2)
      • corresponds

        public <S> boolean corresponds​(OrderedIterable<S> other,
                                       Predicate2<? super T,​? super S> predicate)
        Description copied from interface: OrderedIterable
        Returns true if both OrderedIterables have the same length and predicate returns true for all corresponding elements e1 of this OrderedIterable and e2 of other. The predicate is evaluated for each element at the same position of each OrderedIterable in a forward iteration order. This is a short circuit pattern.
        Specified by:
        corresponds in interface OrderedIterable<T>
        Overrides:
        corresponds in class AbstractImmutableSortedSet<T>
      • forEach

        public void forEach​(int fromIndex,
                            int toIndex,
                            Procedure<? super T> procedure)
        Description copied from interface: OrderedIterable
        Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.
        e.g.
         OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally)
         people.forEach(0, 1, new Procedure<Person>()
         {
             public void value(Person person)
             {
                  LOGGER.info(person.getName());
             }
         });
         

        This code would output ted and mary's names.

        Specified by:
        forEach in interface OrderedIterable<T>
      • forEachWithIndex

        public void forEachWithIndex​(int fromIndex,
                                     int toIndex,
                                     ObjectIntProcedure<? super T> objectIntProcedure)
        Description copied from interface: OrderedIterable
        Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.
        e.g.
         OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally)
         people.forEachWithIndex(0, 1, new ObjectIntProcedure<Person>()
         {
             public void value(Person person, int index)
             {
                  LOGGER.info(person.getName());
             }
         });
         

        This code would output ted and mary's names.

        Specified by:
        forEachWithIndex in interface OrderedIterable<T>
      • indexOf

        public int indexOf​(java.lang.Object object)
        Description copied from interface: OrderedIterable
        Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.
        Specified by:
        indexOf in interface OrderedIterable<T>
        See Also:
        List.indexOf(Object)