Package org.xnio
Class Sequence<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
org.xnio.Sequence<T>
- Type Parameters:
T- the element type
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,List<T>,RandomAccess
public final class Sequence<T>
extends AbstractList<T>
implements List<T>, RandomAccess, Serializable
An immutable sequence of elements. Though this class implements
List, it is in fact
immutable.- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Method Summary
Modifier and TypeMethodDescription<N> Sequence<N>Cast a sequence to a different type if all the contained elements are of the subtype.static <T> Sequence<T>empty()Return an empty sequence.booleanDetermine whether this sequence is equal to another.booleanDetermine whether this sequence is equal to another.get(int index) Get the value at a certain index.inthashCode()Get the hash code for this sequence.booleanisEmpty()Determine whether this sequence is empty.iterator()Get an iterator over the elements of this sequence.static <T> Sequence<T>of(Collection<T> members) Return a sequence of the given members.static <T> Sequence<T>of(T... members) Return a sequence of the given members.intsize()Return the number of elements in this sequence.Object[]toArray()Get a copy of the values array.Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray
-
Method Details
-
of
Return a sequence of the given members.- Type Parameters:
T- the element type- Parameters:
members- the members- Returns:
- a sequence
-
of
Return a sequence of the given members.- Type Parameters:
T- the element type- Parameters:
members- the members- Returns:
- a sequence
-
cast
Cast a sequence to a different type if all the contained elements are of the subtype.- Type Parameters:
N- the new type- Parameters:
newType- the class to cast to- Returns:
- the typecast sequence
- Throws:
ClassCastException- if any elements could not be cast
-
empty
Return an empty sequence.- Type Parameters:
T- the element type- Returns:
- the empty sequence
-
iterator
Get an iterator over the elements of this sequence. -
size
public int size()Return the number of elements in this sequence.- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<T>- Returns:
- the number of elements
-
isEmpty
public boolean isEmpty()Determine whether this sequence is empty.- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Overrides:
isEmptyin classAbstractCollection<T>- Returns:
trueif the sequence has no elements
-
toArray
Get a copy of the values array.- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceList<T>- Overrides:
toArrayin classAbstractCollection<T>- Returns:
- a copy of the values array
-
get
Get the value at a certain index. -
equals
Determine whether this sequence is equal to another.- Specified by:
equalsin interfaceCollection<T>- Specified by:
equalsin interfaceList<T>- Overrides:
equalsin classAbstractList<T>- Parameters:
other- the other sequence- Returns:
trueif they are equal,falseotherwise
-
equals
Determine whether this sequence is equal to another.- Parameters:
other- the other sequence- Returns:
trueif they are equal,falseotherwise
-
hashCode
public int hashCode()Get the hash code for this sequence.- Specified by:
hashCodein interfaceCollection<T>- Specified by:
hashCodein interfaceList<T>- Overrides:
hashCodein classAbstractList<T>- Returns:
- the hash code
-