nz.ac.waikato.jdsl.core.api
Interface InspectableSequence

All Superinterfaces:
InspectableContainer, InspectablePositionalContainer
All Known Subinterfaces:
Sequence
All Known Implementing Classes:
ArraySequence, NodeSequence

public interface InspectableSequence
extends InspectablePositionalContainer

Please refer to the documentation of Sequence.

Version:
JDSL 2.1.1
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 nz.ac.waikato.jdsl.core.api.InspectablePositionalContainer
positions
 
Methods inherited from interface nz.ac.waikato.jdsl.core.api.InspectableContainer
contains, elements, isEmpty, size
 

Method Detail

first

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

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

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

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

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

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

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

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


Copyright © 2009 ModelJUnit Project. All Rights Reserved.