|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.NodeList
net.datastructures.NodeSequence
Implementation of a sequence by means of a doubly linked list.
Field Summary |
Fields inherited from class net.datastructures.NodeList |
header, numElts, trailer |
Constructor Summary | |
NodeSequence()
|
Method Summary | |
Position |
atRank(int rank)
Returns the position containing the element at the given rank; O(n) time. |
protected void |
checkRank(int r,
int n)
Checks whether the given rank is in the range [0, n - 1] |
Object |
elemAtRank(int rank)
Returns the element stored at the given rank; O(n) time |
void |
insertAtRank(int rank,
Object element)
Inserts an element at the given rank; O(n) time. |
int |
rankOf(Position p)
Returns the rank of the element stored at the given position; O(n) time. |
Object |
removeAtRank(int rank)
Removes the element stored at the given rank; O(n) time. |
Object |
replaceAtRank(int rank,
Object element)
Replaces the element stored at the given rank; O(n) time. |
Methods inherited from class net.datastructures.NodeList |
checkPosition, elements, first, insertAfter, insertBefore, insertFirst, insertLast, isEmpty, isFirst, isLast, last, next, positions, prev, remove, replace, size, swapElements, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.datastructures.List |
elements, first, insertAfter, insertBefore, insertFirst, insertLast, isEmpty, last, next, positions, prev, remove, replace, size |
Methods inherited from interface net.datastructures.Vector |
isEmpty, size |
Constructor Detail |
public NodeSequence()
Method Detail |
protected void checkRank(int r, int n) throws BoundaryViolationException
BoundaryViolationException
public Position atRank(int rank)
atRank
in interface Sequence
public int rankOf(Position p) throws InvalidPositionException
rankOf
in interface Sequence
InvalidPositionException
public Object elemAtRank(int rank) throws BoundaryViolationException
elemAtRank
in interface Vector
rank
- Rank to query
BoundaryViolationException
- if r < 0 or
r > Vector.size()
- 1public void insertAtRank(int rank, Object element) throws BoundaryViolationException
insertAtRank
in interface Vector
rank
- Rank at which to replace
BoundaryViolationException
- if r < 0 or
r > Vector.size()
public Object removeAtRank(int rank) throws BoundaryViolationException
removeAtRank
in interface Vector
rank
- Rank at which to replace
BoundaryViolationException
- if r < 0 or
r > Vector.size()
- 1public Object replaceAtRank(int rank, Object element) throws BoundaryViolationException
replaceAtRank
in interface Vector
rank
- Rank at which to replace
BoundaryViolationException
- if r < 0 or
r > Vector.size()
- 1
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |