jdsl.core.api
Interface InspectableSequence

All Superinterfaces:
InspectableContainer, InspectablePositionalContainer
All Known Subinterfaces:
Sequence

public interface InspectableSequence
extends InspectablePositionalContainer

Please refer to the documentation of Sequence.

Version:
$Id: InspectableSequence.java,v 1.3 2000/07/17 17:25:50 lv Exp $
Author:
Mark Handy (mdh), Luca Vismara (lv), Andrew Schwerin (schwerin)
See Also:
InspectablePositionalContainer

Method Summary
 Position after(Position p)
          The next position in the sequence.
 Position atRank(int rank)
          Get the position in the sequence with the specified rank
 Position before(Position p)
          The previous position in the sequence.
 Position first()
          The first position of the sequence.
 boolean isFirst(Position p)
          Check if the given position is the first.
 boolean isLast(Position p)
          Check if the given position is the last.
 Position last()
          The last position of the sequence.
 int rankOf(Position p)
          Get the rank of a given position.
 
Methods inherited from interface jdsl.core.api.InspectablePositionalContainer
positions
 
Methods inherited from interface jdsl.core.api.InspectableContainer
contains, elements, isEmpty, size
 

Method Detail

first

public Position first()
               throws EmptyContainerException
The first position of the sequence.
Returns:
Position of the first element in the sequence
Throws:
EmptyContainerException - if this sequence is empty

last

public Position last()
              throws EmptyContainerException
The last position of the sequence.
Returns:
Position of the last element in the sequence
Throws:
EmptyContainerException - if this sequence is empty

isFirst

public boolean isFirst(Position p)
                throws InvalidAccessorException
Check if the given position is the first.
Parameters:
p - A Position in this sequence
Returns:
True if and only if the given position is the first in the sequence
Throws:
InvalidAccessorException - Thrown if p is not a valid position in this sequence

isLast

public boolean isLast(Position p)
               throws InvalidAccessorException
Check if the given position is the last.
Parameters:
p - A Position in this sequence
Returns:
True if and only if the given position is the last in the sequence
Throws:
InvalidAccessorException - Thrown if p is not a valid position in this sequence

before

public Position before(Position p)
                throws BoundaryViolationException,
                       InvalidAccessorException
The previous position in the sequence.
Parameters:
p - A Position in this sequence
Returns:
Position previous to parameter position p
Throws:
InvalidAccessorException - Thrown if p is not a valid position in this sequence
BoundaryViolationException - if p is the first position of this sequence.

after

public Position after(Position p)
               throws BoundaryViolationException,
                      InvalidAccessorException
The next position in the sequence.
Parameters:
p - A Position in this sequence.
Returns:
Position after parameter position p
Throws:
InvalidAccessorException - Thrown if p is not a valid position in this sequence
BoundaryViolationException - if p is the last position of this sequence.

atRank

public Position atRank(int rank)
                throws BoundaryViolationException
Get the position in the sequence with the specified rank
Parameters:
rank - An integer index of positions in the sequence; the Position returned by first() is the same as that returned by atRank(0)last() is the same as that returned by atRank(size() - 1).
Returns:
position at the specified rank
Throws:
BoundaryViolationException - if rank<0 or rank>=size()

rankOf

public int rankOf(Position p)
           throws InvalidAccessorException
Get the rank of a given position.
Parameters:
p - A Position in this sequence
Returns:
Rank of that element, where first element has rank 0 and the last has rank size() - 1.
Throws:
InvalidAccessorException - if p is not a valid position in this sequence