- Type Parameters:
E- value type
- All Superinterfaces:
Collection<E>,Iterable<E>,SequencedCollection<E>,SequencedSet<E>,Set<E>
A
Set with consistent order of entries. All static factory methods
produce unmodifiable sets.-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> OrderedSet<E> Returns an unmodifiable OrderedSet that contains a copy of the provided Set.booleanCompares the provided object with this map for equality in accordance with the specification of.invalid reference
Map#equals(java.lang.Object)static <E> OrderedSet<E> of()Returns an empty OrderedSet.static <E> OrderedSet<E> of(E element) Returns an OrderedSet with a single element.static <E> OrderedSet<E> of(E... elements) Returns an OrderedSet of the provided elements.static <E> OrderedSet<E> of(E e1, E e2) Returns an OrderedSet with two elements.static <E> OrderedSet<E> of(E e1, E e2, E e3) Returns an OrderedSet with three elements.static <E> OrderedSet<E> of(E e1, E e2, E e3, E e4) Returns an OrderedSet with four elements.static <E> OrderedSet<E> of(E e1, E e2, E e3, E e4, E e5) Returns an OrderedSet with five elements.reversed()values()AListcontaining all the values of this OrderedSet.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.SequencedCollection
addFirst, addLast, getFirst, getLast, removeFirst, removeLast
-
Method Details
-
values
AListcontaining all the values of this OrderedSet.Because Set equality ignores order, code needing to verify whether an OrderedSet contains the same values in the same order should also check for equality of the values list.
- Returns:
- values as list
-
reversed
OrderedSet<E> reversed()- Specified by:
reversedin interfaceSequencedCollection<E>- Specified by:
reversedin interfaceSequencedSet<E>
-
equals
Compares the provided object with this map for equality in accordance with the specification of.invalid reference
Map#equals(java.lang.Object)Because Map equality does not depends on order, code needing to verify whether an OrderedMap contains the same mappings in the same order should also check for equality of the
list.invalid reference
#keys() -
of
Returns an empty OrderedSet.- Type Parameters:
E- value type- Returns:
- empty OrderedSet
-
of
Returns an OrderedSet with a single element.- Type Parameters:
E- element type- Parameters:
element- element- Returns:
- an OrderedSet of the provided element
- Throws:
NullPointerException- if element is null
-
of
Returns an OrderedSet with two elements.- Type Parameters:
E- element type- Parameters:
e1- first elemente2- second element- Returns:
- an OrderedSet of the provided elements
- Throws:
NullPointerException- if any elements are nullIllegalArgumentException- if any elements are duplicated
-
of
Returns an OrderedSet with three elements.- Type Parameters:
E- element type- Parameters:
e1- first elemente2- second elemente3- third element- Returns:
- an OrderedSet of the provided elements
- Throws:
NullPointerException- if any elements are nullIllegalArgumentException- if any elements are duplicated
-
of
Returns an OrderedSet with four elements.- Type Parameters:
E- element type- Parameters:
e1- first elemente2- second elemente3- third elemente4- fourth element- Returns:
- an OrderedSet of the provided elements
- Throws:
NullPointerException- if any elements are nullIllegalArgumentException- if any elements are duplicated
-
of
Returns an OrderedSet with five elements.- Type Parameters:
E- element type- Parameters:
e1- first elemente2- second elemente3- third elemente4- fourth elemente5- fifth element- Returns:
- an OrderedSet of the provided elements
- Throws:
NullPointerException- if any elements are nullIllegalArgumentException- if any elements are duplicated
-
of
Returns an OrderedSet of the provided elements.- Type Parameters:
E- element type- Parameters:
elements- elements- Returns:
- an OrderedSet of the provided elements
-
copyOf
Returns an unmodifiable OrderedSet that contains a copy of the provided Set. The order will be the same as the iteration order of the set.If the set is already an unmodifiable OrderedSet it may be returned as is.
- Type Parameters:
E- element type- Parameters:
set- set to copy- Returns:
- an ordered set copy of the provided set
- Throws:
NullPointerException- if any element is null or the set is null
-