public final class Sets extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Set<T> |
asImmutableSet(Iterable<? extends T> iterable)
Create and return an immutable set containing the unique elements returned by the
specified iterable.
|
static <T> Set<T> |
asImmutableSet(Iterator<? extends T> iterator)
Create and return an immutable set containing the unique elements returned by the
specified iterator.
|
static <T> Set<T> |
asImmutableSet(T... elements)
Create and return an immutable set containing the unique elements in
elements . |
static <T extends Comparable<? super T>> |
asImmutableSortedSet(Iterable<? extends T> iterable)
Create and return an immutable sorted set containing the unique elements in the specified iterable
sorted by their natural order.
|
static <T extends Comparable<? super T>> |
asImmutableSortedSet(Iterable<? extends T> iterable,
Comparator<? super T> comparator)
Create and return an immutable sorted set containing the unique elements in the specified iterable
sorted according to the specified comparator.
|
static <T extends Comparable<? super T>> |
asImmutableSortedSet(Iterator<? extends T> iterator)
Create and return an immutable sorted set containing the unique elements in the specified iterator
sorted by their natural order.
|
static <T extends Comparable<? super T>> |
asImmutableSortedSet(Iterator<? extends T> iterator,
Comparator<? super T> comparator)
Create and return an immutable sorted set containing the unique elements in the specified iterator
sorted according to the specified comparator.
|
static <T extends Comparable<? super T>> |
asImmutableSortedSet(T... elements)
Create and return an immutable sorted set containing the unique elements in
elements
sorted by their natural order. |
static <T> Set<T> |
asSet(Iterable<? extends T> iterable)
Create and return a set containing the unique elements returned by the
specified iterable.
|
static <T> Set<T> |
asSet(Iterator<? extends T> iterator)
Create and return a set containing the unique elements returned by the
specified iterator.
|
static <T> Set<T> |
asSet(T... elements)
Create and return a set containing the unique elements in
elements . |
static <T> SortedSet<T> |
asSortedSet(Iterable<? extends T> iterable)
Create and return a sorted set containing the unique elements returned by the
specified iterable sorted in their natural order.
|
static <T> SortedSet<T> |
asSortedSet(Iterable<? extends T> iterable,
Comparator<? super T> comparator)
Create and return a sorted set containing the unique elements returned by the
specified iterable sorted according to the specified comparator.
|
static <T> SortedSet<T> |
asSortedSet(Iterator<? extends T> iterator)
Create and return a sorted set containing the unique elements returned by the
specified iterator sorted in their natural order.
|
static <T> SortedSet<T> |
asSortedSet(Iterator<? extends T> iterator,
Comparator<? super T> comparator)
Create and return a sorted set containing the unique elements returned by the
specified iterator sorted according to the specified comparator.
|
static <T> SortedSet<T> |
asSortedSet(T... elements)
Create and return a sorted set containing the unique elements in
elements
sorted in their natural order. |
static <T> ConcurrentSkipListSet<T> |
createConcurrentSkipListSet()
Create and return a new instance of ConcurrentSkipListSet.
|
static <T> ConcurrentSkipListSet<T> |
createConcurrentSkipListSet(Collection<? extends T> elements)
Create and return a new instance of ConcurrentSkipListSet containing the elements
of the specified collection.
|
static <T> ConcurrentSkipListSet<T> |
createConcurrentSkipListSet(Collection<? extends T> elements,
Comparator<? super T> comparator)
Create and return a new instance of ConcurrentSkipListSet containing the elements
of the specified collection sorted according to the specified comparator.
|
static <T> ConcurrentSkipListSet<T> |
createConcurrentSkipListSet(Comparator<? super T> comparator)
Create and return a new instance of ConcurrentSkipListSet sorted according to the specified
comparator.
|
static <T> ConcurrentSkipListSet<T> |
createConcurrentSkipListSet(SortedSet<T> sortedSet)
Create and return a new instance of ConcurrentSkipListSet containing the same elements
in the same order as the specified sorted set.
|
static <T> CopyOnWriteArraySet<T> |
createCopyOnWriteArraySet()
Create and return a new instance of CopyOnWriteArraySet.
|
static <T> CopyOnWriteArraySet<T> |
createCopyOnWriteArraySet(Collection<? extends T> elements)
Create and return a new instance of CopyOnWriteArraySet containing the elements
of the specified collection.
|
static <T> NavigableSet<T> |
createNavigableSet()
Create and return a new instance of NavigableSet.
|
static <T> NavigableSet<T> |
createNavigableSet(Collection<? extends T> elements)
Create and return a new instance of NavigableSet containing the elements
of the specified collection.
|
static <T> NavigableSet<T> |
createNavigableSet(Collection<? extends T> elements,
Comparator<? super T> comparator)
Create and return a new instance of NavigableSet containing the elements
of the specified collection sorted according to the specified comparator.
|
static <T> NavigableSet<T> |
createNavigableSet(Comparator<? super T> comparator)
Create and return a new instance of NavigableSet sorted according to the specified
comparator.
|
static <T> NavigableSet<T> |
createNavigableSet(SortedSet<T> sortedSet)
Create and return a new instance of NavigableSet containing the same elements
in the same order as the specified sorted set.
|
static <T> Set<T> |
createNonBlockingSet()
Create and return a new non-blocking implementation of Set.
|
static <T> Set<T> |
createNonBlockingSet(Collection<? extends T> elements)
Create and return a new non-blocking implementation of Set containing the elements
of the specified collection.
|
static <T> Set<T> |
createSet()
Create and return a new instance of Set.
|
static <T> Set<T> |
createSet(Collection<? extends T> elements)
Create and return a new instance of Set containing the elements of the
specified collection.
|
static <T> Set<T> |
createSet(int initialCapacity)
Create and return a new instance of Set with the specified initial capacity.
|
static <T> Set<T> |
createSet(int initialCapacity,
float loadFactor)
Create and return a new instance of Set with the specified initial capacity
and load factor.
|
static <T> SortedSet<T> |
createSortedSet()
Create and return a new instance of SortedSet.
|
static <T> SortedSet<T> |
createSortedSet(Collection<? extends T> elements)
Create and return a new instance of SortedSet containing the elements
of the specified collection.
|
static <T> SortedSet<T> |
createSortedSet(Collection<? extends T> elements,
Comparator<? super T> comparator)
Create and return a new instance of SortedSet containing the elements
of the specified collection sorted according to the specified comparator.
|
static <T> SortedSet<T> |
createSortedSet(Comparator<? super T> comparator)
Create and return a new instance of SortedSet sorted according to the specified
comparator.
|
static <T> SortedSet<T> |
createSortedSet(SortedSet<T> sortedSet)
Create and return a new instance of SortedSet containing the same elements
in the same order as the specified sorted set.
|
static <T> Set<T> |
emptySet()
Create and return a new empty set.
|
static <T> Set<T> |
immutableSet(Set<? extends T> set)
Create and return an immutable set containing the elements in the specified set, in order.
|
static <T> SortedSet<T> |
immutableSortedSet(SortedSet<T> sortedSet)
Create and return an immutable sorted set containing the elements in the specified
sorted set, sorted by the same comparator.
|
static <T> Set<T> |
unmodifiableSet(Set<? extends T> set)
Create and return an unmodifiable view of the specified set.
|
static <T> SortedSet<T> |
unmodifiableSortedSet(SortedSet<T> sortedSet)
Create and return an unmodifiable view of the specified sorted set.
|
public static <T> Set<T> emptySet()
Collections.emptySet()
.T
- element typepublic static <T> Set<T> asSet(T... elements)
elements
.T
- element typeelements
- variable number of elements to be added to the
returned setelements
public static <T> Set<T> asSet(Iterator<? extends T> iterator)
T
- element typeiterator
- iterator, must not be nullpublic static <T> Set<T> asSet(Iterable<? extends T> iterable)
T
- element typeiterable
- iterable, must not be nullpublic static <T> SortedSet<T> asSortedSet(T... elements)
elements
sorted in their natural order.T
- element typeelements
- variable number of elements to be added to the
returned sorted setelements
sorted in their natural orderpublic static <T> SortedSet<T> asSortedSet(Iterator<? extends T> iterator)
T
- element typeiterator
- iterator, must not be nullpublic static <T> SortedSet<T> asSortedSet(Iterable<? extends T> iterable)
T
- element typeiterable
- iterable, must not be nullpublic static <T> SortedSet<T> asSortedSet(Iterator<? extends T> iterator, Comparator<? super T> comparator)
T
- element typeiterator
- iterator, must not be nullcomparator
- comparator to be used to sort the returned sorted setpublic static <T> SortedSet<T> asSortedSet(Iterable<? extends T> iterable, Comparator<? super T> comparator)
T
- element typeiterable
- iterable, must not be nullcomparator
- comparator to be used to sort the returned sorted setpublic static <T> Set<T> asImmutableSet(T... elements)
elements
.
The returned immutable set is a high-performance, immutable Set
with reliable
iteration order.T
- element typeelements
- variable number of elements to be added to the
returned immutable setelements
public static <T> Set<T> asImmutableSet(Iterator<? extends T> iterator)
Set
with reliable iteration order.T
- element typeiterator
- iterator, must not be nullpublic static <T> Set<T> asImmutableSet(Iterable<? extends T> iterable)
Set
with reliable iteration order.T
- element typeiterable
- iterable, must not be nullpublic static <T extends Comparable<? super T>> SortedSet<T> asImmutableSortedSet(T... elements)
elements
sorted by their natural order. The returned immutable sorted set is a high-performance, immutable
SortedSet
that stores its elements in a sorted array.T
- element typeelements
- variable number of elements to be added to the
returned immutable sorted setelements
sorted by their natural orderpublic static <T extends Comparable<? super T>> SortedSet<T> asImmutableSortedSet(Iterator<? extends T> iterator)
SortedSet
that stores its elements in a sorted array.T
- element typeiterator
- iterator, must not be nullpublic static <T extends Comparable<? super T>> SortedSet<T> asImmutableSortedSet(Iterable<? extends T> iterable)
SortedSet
that stores its elements in a sorted array.T
- element typeiterable
- iterable, must not be nullpublic static <T extends Comparable<? super T>> SortedSet<T> asImmutableSortedSet(Iterator<? extends T> iterator, Comparator<? super T> comparator)
SortedSet
that stores its elements in a sorted array.T
- element typeiterator
- iterator, must not be nullcomparator
- comparator to be used to sort the returned immutable sorted setpublic static <T extends Comparable<? super T>> SortedSet<T> asImmutableSortedSet(Iterable<? extends T> iterable, Comparator<? super T> comparator)
SortedSet
that stores its elements in a sorted array.T
- element typeiterable
- iterable, must not be nullcomparator
- comparator to be used to sort the returned immutable sorted setpublic static <T> Set<T> createSet()
T
- element typepublic static <T> Set<T> createSet(Collection<? extends T> elements)
T
- element typeelements
- elements to be added to the returned set, must not be nullpublic static <T> Set<T> createSet(int initialCapacity)
T
- element typeinitialCapacity
- initial capacitypublic static <T> Set<T> createSet(int initialCapacity, float loadFactor)
T
- element typeinitialCapacity
- initial capacityloadFactor
- load factorpublic static <T> SortedSet<T> createSortedSet()
T
- element typepublic static <T> SortedSet<T> createSortedSet(Collection<? extends T> elements)
T
- element typeelements
- elements to be added to the returned set, must not be nullpublic static <T> SortedSet<T> createSortedSet(Comparator<? super T> comparator)
T
- element typecomparator
- comparator to be used to sort the returned setpublic static <T> SortedSet<T> createSortedSet(Collection<? extends T> elements, Comparator<? super T> comparator)
T
- element typeelements
- elements to be added to the returned set, must not be nullcomparator
- comparator to be used to sort the returned setpublic static <T> SortedSet<T> createSortedSet(SortedSet<T> sortedSet)
T
- element typesortedSet
- sorted set of elements to be added to the returned set, must not be nullpublic static <T> NavigableSet<T> createNavigableSet()
T
- element typepublic static <T> NavigableSet<T> createNavigableSet(Collection<? extends T> elements)
T
- element typeelements
- elements to be added to the returned set, must not be nullpublic static <T> NavigableSet<T> createNavigableSet(Comparator<? super T> comparator)
T
- element typecomparator
- comparator to be used to sort the returned setpublic static <T> NavigableSet<T> createNavigableSet(Collection<? extends T> elements, Comparator<? super T> comparator)
T
- element typeelements
- elements to be added to the returned set, must not be nullcomparator
- comparator to be used to sort the returned setpublic static <T> NavigableSet<T> createNavigableSet(SortedSet<T> sortedSet)
T
- element typesortedSet
- sorted set of elements to be added to the returned set, must not be nullpublic static <T> ConcurrentSkipListSet<T> createConcurrentSkipListSet()
T
- element typepublic static <T> ConcurrentSkipListSet<T> createConcurrentSkipListSet(Collection<? extends T> elements)
T
- element typeelements
- elements to be added to the returned set, must not be nullpublic static <T> ConcurrentSkipListSet<T> createConcurrentSkipListSet(Comparator<? super T> comparator)
T
- element typecomparator
- comparator to be used to sort the returned setpublic static <T> ConcurrentSkipListSet<T> createConcurrentSkipListSet(Collection<? extends T> elements, Comparator<? super T> comparator)
T
- element typeelements
- elements to be added to the returned set, must not be nullcomparator
- comparator to be used to sort the returned setpublic static <T> ConcurrentSkipListSet<T> createConcurrentSkipListSet(SortedSet<T> sortedSet)
T
- element typesortedSet
- sorted set of elements to be added to the returned set, must not be nullpublic static <T> CopyOnWriteArraySet<T> createCopyOnWriteArraySet()
T
- element typepublic static <T> CopyOnWriteArraySet<T> createCopyOnWriteArraySet(Collection<? extends T> elements)
T
- element typeelements
- elements to be added to the returned set, must not be nullpublic static <T> Set<T> createNonBlockingSet()
T
- element typepublic static <T> Set<T> createNonBlockingSet(Collection<? extends T> elements)
T
- element typeelements
- elements to be added to the returned set, must not be nullpublic static <T> Set<T> unmodifiableSet(Set<? extends T> set)
UnsupportedOperationException
.T
- element typeset
- set to view, must not be nullpublic static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> sortedSet)
subSet
,
headSet
, or tailSet
views, result in an
UnsupportedOperationException
.T
- element typesortedSet
- sorted set to view, must not be nullpublic static <T> Set<T> immutableSet(Set<? extends T> set)
Set
with reliable iteration order.T
- element typeset
- set to copy, must not be nullpublic static <T> SortedSet<T> immutableSortedSet(SortedSet<T> sortedSet)
T
- element typesortedSet
- sorted set to copy, must not be nullCopyright (c) 2008-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).