|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Sequence<E>
A sequentially ordered set of elements that cannot be mutated (changed).
Method Summary | |
---|---|
Sequence<E> |
append(Sequence<E> sequence)
Appends the given sequence to this sequence and returns a new sequence. |
Sequence<E> |
clone()
Returns a clone of this Sequence. |
Sequence<E> |
delete(int fromPosition,
int toPosition)
Deletes elements between the given positions and returns the resulting sequence. |
boolean |
equals(Object o)
Determines equality for this Sequence. |
E |
get(int index)
Returns the element at the given index in the sequence. |
SequenceIterator<E> |
getIterator()
Returns an iterator for this Sequence. |
SequenceIterator<E> |
getIterator(int position)
Returns an iterator for this Sequence from the given position. |
Sequence<E> |
getSubSequence(int fromPosition,
int toPosition)
Returns a sequence that contains a subset of the elements of this sequence within the given positional range. |
int |
hashCode()
Returns a hash code for this Sequence. |
int |
indexOf(E e)
Returns the first index of the given element in the sequence, or less than zero if it is not present. |
int |
indexOf(int position,
E e)
Returns the first index of the given element in the sequence from the given position, or less than zero if it is not present. |
Sequence<E> |
insert(int position,
Sequence<E> sequence)
Inserts the given sequence at the given position and returns the resulting sequence. |
boolean |
isEmpty()
Returns true is the sequence is empty, false otherwise. |
int |
lastIndexOf(E e)
Returns the last index of the given element in the sequence, or less than zero if it is not present. |
int |
lastIndexOf(int position,
E e)
Returns the last index of the given element in the sequence from the given position, or less than zero if it is not present. |
int |
length()
Returns the number of elements held in this sequence. |
String |
toString()
Returns a String representation of this Sequence. |
Method Detail |
---|
E get(int index) throws IndexOutOfBoundsException
get
in interface ReadOnlyArray<E>
index
- The index of the element to return.
IndexOutOfBoundsException
- If the given index is out of range
(index < 0 || index >= length()
).int length()
length
in interface ReadOnlyArray<E>
Sequence<E> append(Sequence<E> sequence) throws NullPointerException
sequence
- The sequence to append to this sequence.
NullPointerException
- If sequence
is null
.Sequence<E> getSubSequence(int fromPosition, int toPosition) throws PositionOutOfBoundsException
fromPosition
- The position from which to take the subsequence.toPosition
- The position to which to take the subsequence.
PositionOutOfBoundsException
- If
(fromPosition < 0 || toPosition > length() || fromPosition > toPosition)
evaluates to
true
.Sequence<E> insert(int position, Sequence<E> sequence) throws PositionOutOfBoundsException, NullPointerException
position
- The position at which to insert the given sequence.sequence
- The sequence to insert at the given position.
PositionOutOfBoundsException
- If position
is less than zero or greater than the
length
of this Sequence. If (fromIndex < 0 || fromIndex > length())
holds
true
.
NullPointerException
- If sequence
is null
.Sequence<E> delete(int fromPosition, int toPosition) throws PositionOutOfBoundsException
fromPosition
- The position from which to start deleting elements.toPosition
- The position to which to start deleting elements.
PositionOutOfBoundsException
- If
(fromPosition < 0 || toPosition > length() || fromPosition > toPosition)
evaluates to
true
.int indexOf(E e)
e
- The element to find the first index of.
int indexOf(int position, E e) throws PositionOutOfBoundsException
position
- The position from which to find the element.e
- The element to find the first index of from the given position.
PositionOutOfBoundsException
- If position
is less than zero or greater than the
length
of this Sequence. If (fromIndex < 0 || fromIndex > length())
holds
true
.int lastIndexOf(E e)
e
- The element to find the last index of.
int lastIndexOf(int position, E e) throws PositionOutOfBoundsException
position
- The position from which to find the element.e
- The element to find the last index of from the given position.
PositionOutOfBoundsException
- If position
is less than zero or greater than the
length
of this Sequence. If (fromIndex < 0 || fromIndex > length())
holds true
.SequenceIterator<E> getIterator()
SequenceIterator<E> getIterator(int position) throws PositionOutOfBoundsException
position
- The position from which the iterator should iterate.
PositionOutOfBoundsException
- If position
is less than zero or greater than the
length
of this Sequence. If (fromIndex < 0 || fromIndex > length())
holds true
.boolean isEmpty()
true
is the sequence is empty, false
otherwise.
true
is the sequence is empty, false
otherwise.String toString()
toString
in class Object
boolean equals(Object o)
true
if each element in this
Sequence is equal to each element in the Sequence that is passed as an argument, returns
false
otherwise. Equal elements in a different order of two Sequence instances deems the
two Sequence instances unequal and therefore, false
is returned. Implementations of this
method must adhere to the contract set out by Object.equals(Object)
.
equals
in class Object
o
- The object to test equality for.
true
if each element in this Sequence is equal to each element in the
Sequence that is passed as an argument, returns false
otherwise.int hashCode()
Object.hashCode()
.
hashCode
in class Object
Sequence<E> clone()
clone
in interface ReadOnlyArray<E>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |