datastructures

net.datastructures
Interface Vector

All Known Subinterfaces:
Sequence
All Known Implementing Classes:
ArrayVector, NodeSequence

public interface Vector

Interface for a vector.

Author:
Michael Goodrich, Roberto Tamassia

Method Summary
 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.
 

Method Detail

size

public int size()
Returns the number of elements in the vector.


isEmpty

public boolean isEmpty()
Returns whether the vector is empty.


elemAtRank

public Object elemAtRank(int r)
                  throws BoundaryViolationException
Returns the element stored at the given rank.

Parameters:
r - Rank to query
Throws:
BoundaryViolationException - if r < 0 or r > size() - 1

replaceAtRank

public Object replaceAtRank(int r,
                            Object e)
                     throws BoundaryViolationException
Replaces the element stored at the given rank.

Parameters:
r - Rank at which to replace
Throws:
BoundaryViolationException - if r < 0 or r > size() - 1

insertAtRank

public void insertAtRank(int r,
                         Object e)
                  throws BoundaryViolationException
Inserts an element at the given rank.

Parameters:
r - Rank at which to replace
Throws:
BoundaryViolationException - if r < 0 or r > size()

removeAtRank

public Object removeAtRank(int r)
                    throws BoundaryViolationException
Removes the element stored at the given rank.

Parameters:
r - Rank at which to replace
Throws:
BoundaryViolationException - if r < 0 or r > size() - 1

datastructures