|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.ArrayVector
Realization of a vector by means of an array. The array has initial length 16 and is doubled when the size of the vector exceeds the capacity of the array. No shrinking of the array is performed.
Constructor Summary | |
ArrayVector()
Creates the vector with initial capacity 16. |
Method Summary | |
protected void |
checkRank(int r,
int n)
Checks whether the given rank is in the range [0, n - 1] |
Object |
elemAtRank(int r)
Returns the element stored at the given rank. |
void |
insertAtRank(int r,
Object e)
Inserts an element at the given rank. |
boolean |
isEmpty()
Returns whether the vector is empty. |
Object |
removeAtRank(int r)
Removes the element stored at the given rank. |
Object |
replaceAtRank(int r,
Object e)
Replaces the element stored at the given rank. |
int |
size()
Returns the number of elements in the vector. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ArrayVector()
Method Detail |
public int size()
size
in interface Vector
public boolean isEmpty()
isEmpty
in interface Vector
public Object elemAtRank(int r) throws BoundaryViolationException
elemAtRank
in interface Vector
r
- Rank to query
BoundaryViolationException
- if r < 0 or
r > Vector.size()
- 1public Object replaceAtRank(int r, Object e) throws BoundaryViolationException
replaceAtRank
in interface Vector
r
- Rank at which to replace
BoundaryViolationException
- if r < 0 or
r > Vector.size()
- 1public void insertAtRank(int r, Object e) throws BoundaryViolationException
insertAtRank
in interface Vector
r
- Rank at which to replace
BoundaryViolationException
- if r < 0 or
r > Vector.size()
public Object removeAtRank(int r) throws BoundaryViolationException
removeAtRank
in interface Vector
r
- Rank at which to replace
BoundaryViolationException
- if r < 0 or
r > Vector.size()
- 1protected void checkRank(int r, int n) throws BoundaryViolationException
BoundaryViolationException
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |