jdsl.simple.api
Interface RankedSequence

All Known Subinterfaces:
BookSequence
All Known Implementing Classes:
NodeRankedSequence

public abstract interface RankedSequence
extends Container

Interface for a ranked sequence.

A ranked sequence is a collection of linearly arranged elements that are accessed, inserted, and removed by their rank. The rank of an element is the number of elements preceding it, that is, in a ranked sequence with n elements, the first element has rank 0, the second element has rank 1, ..., the last element has rank n-1.

Author:
Michael T. Goodrich, Mark Handy, Roberto Tamassia
See Also:
BoundaryViolationException, Container, Sequence, PositionalSequence

Method Summary
 java.lang.Object elemAtRank(int rank)
          Inspect the element at a specified rank.
 void insertElemAtRank(int rank, java.lang.Object element)
          Insert an element at a specified rank.
 java.lang.Object removeElemAtRank(int rank)
          Remove the element at a specified rank.
 java.lang.Object replaceElemAtRank(int rank, java.lang.Object newElement)
          Replace the element at a specified rank.
 
Methods inherited from interface jdsl.simple.api.SimpleContainer
isEmpty, size
 

Method Detail

elemAtRank

public java.lang.Object elemAtRank(int rank)
                            throws BoundaryViolationException
Inspect the element at a specified rank.
Parameters:
rank - rank of the element to be inspected.
Returns:
element with the specified rank.
Throws:
BoundaryViolationException - if the specified rank is not between 0 and size()-1.

replaceElemAtRank

public java.lang.Object replaceElemAtRank(int rank,
                                          java.lang.Object newElement)
                                   throws BoundaryViolationException
Replace the element at a specified rank.
Parameters:
rank - rank of the element to be replaced.
newElement - new element at the specified rank.
Returns:
old element at the specified rank.
Throws:
BoundaryViolationException - is thrown if the specified rank is not between 0 and size()-1.

insertElemAtRank

public void insertElemAtRank(int rank,
                             java.lang.Object element)
                      throws BoundaryViolationException
Insert an element at a specified rank.
Parameters:
rank - rank at which the new element should be inserted.
element - element to be inserted.
Throws:
BoundaryViolationException - is thrown if the specified rank is not between 0 and size().

removeElemAtRank

public java.lang.Object removeElemAtRank(int rank)
                                  throws BoundaryViolationException
Remove the element at a specified rank.
Parameters:
rank - rank of the element to be removed.
Returns:
element to be removed.
Throws:
BoundaryViolationException - is thrown if the specified rank is not between 0 and size()-1.