public abstract class IntSeq extends Object
IntSeq
is a collection of int
numbers.
The sequence can have a special "current element," which is specified and
accessed through four methods (start, getCurrent, advance, and isCurrent).Constructor and Description |
---|
IntSeq() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addAfter(int element)
Add a new element to this sequence, after the current element.
|
abstract void |
addAll(IntSeq addend)
Place the contents of another sequence at the end of this sequence.
|
abstract void |
addBefore(int element)
Add a new element to this sequence, before the current element.
|
abstract void |
addFirst(int element)
Add a new element to the beginning of this sequence.
|
abstract void |
addLast(int element)
Add a new element to the end of this sequence.
|
abstract void |
advance()
Move forward, so that the current element is now the next element
in this sequence.
|
abstract IntSeq |
catenation(IntSeq s2)
Create a new sequence that contains all the elements from
this sequence followed by another sequence.
|
abstract boolean |
contains(int target)
Method to determine if a particular element
is in this sequence.
|
abstract int |
getCurrentValue()
Accessor method to get the value in the current element of this sequence.
|
abstract int |
indexOf(int target)
Returns the index of the first occurrence of the specified element in
this sequence, or -1 if this sequence does not contain the element.
|
abstract void |
invalidateCurrent()
Set the state of this sequence so that it does not have a current element.
|
abstract boolean |
isCurrent()
Accessor method to determine whether this sequence has a specified
current element that can be retrieved with the getCurrentValue() method.
|
abstract void |
removeCurrent()
Remove the current element from this sequence.
|
abstract void |
removeFirst()
Remove the element at the beginning of this sequence.
|
abstract void |
removeLast()
Remove the element at the end of this sequence.
|
abstract IntSeq |
reverse()
Create a new sequence that contains all the elements from
this sequence in the reverse order.
|
abstract void |
setCurrent(int i)
Set the current element to be the i'th element of this sequence
(starting with the 0'th element at the head).
|
abstract void |
setCurrentValue(int element)
Mutator method to set the value in the current element of this sequence.
|
abstract int |
size()
Determine the number of elements in this sequence.
|
abstract void |
start()
Set the current element at the front of this sequence.
|
abstract IntSeq |
subSeq(int fromIndex,
int toIndex)
Create a new sequence that contains all the elements from
this sequence that are between the indices fromIndex, inclusive,
and toIndex, exclusive.
|
abstract int[] |
toArray()
Returns an array containing all of the elements in this sequence.
|
abstract String |
toString()
Returns a String containing a representation of all the elements
in this sequence.
|
public abstract void addAfter(int element)
element
- the new element that is being addedpublic abstract void addAll(IntSeq addend)
addend
- a sequence whose contents will be placed at the end of this sequencepublic abstract void addBefore(int element)
element
- the new element that is being addedpublic abstract void addFirst(int element)
element
- the new element that is being addedpublic abstract void addLast(int element)
element
- the new element that is being addedpublic abstract void advance()
none
- IllegalStateException
- Indicates that there is no current element,
so advance() may not be called.public abstract IntSeq catenation(IntSeq s2)
s2
- the second sequencepublic abstract boolean contains(int target)
target
- the element that needs to be found in this sequencepublic abstract int getCurrentValue()
none
- IllegalStateException
- Indicates that there is no current element,
so getCurrentValue() may not be called.public abstract int indexOf(int target)
target
- the element that needs to be found in this sequencepublic abstract void invalidateCurrent()
none
- public abstract boolean isCurrent()
none
- public abstract void removeCurrent()
none
- IllegalStateException
- Indicates that there is no current element,
so removeCurrent() may not be called.public abstract void removeFirst()
none
- IllegalStateException
- Indicates that the sequence is empty,
so removeFirst() may not be called.public abstract void removeLast()
none
- IllegalStateException
- Indicates that the sequence is empty,
so removeLast() may not be called.public abstract IntSeq reverse()
none
- public abstract void setCurrent(int i)
i
- the index of the element to make the current elementIndexOutOfBoundsException
- Indicates that i is less than 0 or greater than
size-1 (i < 0 || i >= size).public abstract void setCurrentValue(int element)
element
- the new value that is to be placed in the current elementIllegalStateException
- Indicates that there is no current element,
so setCurrentValue() may not be called.public abstract int size()
none
- public abstract void start()
none
- public abstract IntSeq subSeq(int fromIndex, int toIndex)
fromIndex
- low endpoint (inclusive) of the sub sequencetoIndex
- high endpoint (exclusive) of the sub sequenceIllegalArgumentException
- if the endpoint indices are out of order (fromIndex > toIndex)IndexOutOfBoundsException
- endpoint index value out of range (fromIndex < 0 || toIndex > size)public abstract int[] toArray()
none
- public abstract String toString()