Package de.espirit.common.util
Interface OrderedSet<E>
- Type Parameters:
E
- the type of elements contained in the set
- All Superinterfaces:
Collection<E>
,Iterable<E>
,Set<E>
A
Set
retaining the iteration order- Since:
- 4.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant indicating that a value is newly added -
Method Summary
Modifier and TypeMethodDescriptionint
Adds an element at the given indexint
Adds an element at the beginningint
Adds an element at the endget
(int index) Returns the element with the given indexgetFirst()
Returns the first elementgetLast()
Returns the last elementint
Returns the index of an elementremove
(int index) Removes the element with the given indexReplaces the element at the given indexMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
NEW_VALUE
static final int NEW_VALUEConstant indicating that a value is newly added- Since:
- 4.0
- See Also:
-
-
Method Details
-
get
Returns the element with the given index- Parameters:
index
- the index of the element- Returns:
- the element with the given index
- Throws:
IndexOutOfBoundsException
- if the index is out of range- Since:
- 4.0
-
getFirst
Returns the first element- Returns:
- the first element
- Throws:
IndexOutOfBoundsException
- if the set does not contain any elements- Since:
- 4.0
-
getLast
Returns the last element- Returns:
- the last element
- Throws:
IndexOutOfBoundsException
- if the set does not contain any elements- Since:
- 4.0
-
set
Replaces the element at the given index- Parameters:
index
- the index of the element to replaceelement
- the new element- Returns:
- the previous element at the given index
- Throws:
IndexOutOfBoundsException
- if the index is out of range- Since:
- 4.0
-
add
Adds an element at the given index- Parameters:
index
- the index of the elementelement
- the element to add- Returns:
- the old index of the element if it was already contained in the set,
NEW_VALUE
otherwise - Throws:
IndexOutOfBoundsException
- if the index is out of range- Since:
- 4.0
-
addFirst
Adds an element at the beginning- Parameters:
element
- the element to add- Returns:
- the old index of the element if it was already contained in the set,
NEW_VALUE
otherwise - Since:
- 4.0
-
addLast
Adds an element at the end- Parameters:
element
- the element to add- Returns:
- the old index of the element if it was already contained in the set,
NEW_VALUE
otherwise - Since:
- 4.0
-
remove
Removes the element with the given index- Parameters:
index
- the index of the element to remove- Returns:
- the removed element
- Throws:
IndexOutOfBoundsException
- if the index is out of range- Since:
- 4.0
-
indexOf
Returns the index of an element- Parameters:
element
- the element to find- Returns:
- the index of the element or -1 if it is not contained in the set
- Since:
- 4.0
-