scranton.list
Interface PositionalList

All Known Implementing Classes:
PositionalListVia2Stacks

public interface PositionalList

A positional list may be specified as an ordered pair this = (R, L), where L and R are n-tuples, L = () or (l0, l1, ..., l#(L)-1 and R = () or (r0, r1, ..., r#(R)-1 L is the sublist to the left of the current position and R is the sublist to the right of the current positon


Method Summary
 boolean atFront()
          Reports whether or not current viewing position is at front of list
 boolean atRear()
          Reports whether or not current viewing position is at rear of list
 PositionalList factory()
          Returns an empty PositionalList implementation of the type used in the method's application.
 void insert(java.lang.Object obj)
          Inserts obj at the current position in the list.
 boolean isEmpty()
          Reports whether or not the list is empty (i.e., contains no items).
 void next()
          Moves current viewing position one object towards the rear, if possible.
 void previous()
          Moves current viewing position one place towards the front, if possible.
 java.lang.Object remove()
          Removes the current item from the list
 void replace(java.lang.Object obj)
          Replaces item at current position in the list with obj.
 void toFront()
          Moves current viewing position to front of list Pre: none Post: L'==(), R'==(L, R)
 void toRear()
          Moves current viewing position to rear of list Pre: none Post: L'==(L, R), R'==()
 java.lang.String toString()
          Return a string representation of a positonal list.
 java.lang.Object view()
          Returns a reference to the current item in list.
 

Method Detail

view

public java.lang.Object view()
Returns a reference to the current item in list.

Returns:
Object, a reference to current item in list Pre: !atRear(), equivalently R!=() Post: this' = this Returns: r0

replace

public void replace(java.lang.Object obj)
Replaces item at current position in the list with obj. Pre: !atRear(), equivalently R!=() Post: r0' = obj

Parameters:
obj - The object replacing the current object in the list.

insert

public void insert(java.lang.Object obj)
Inserts obj at the current position in the list. Pre: none Post: R' = (obj, R)

Parameters:
obj - New item inserted at the current position.

remove

public java.lang.Object remove()
Removes the current item from the list

Returns:
Object, the item that was removed Pre: !atRear(), equivalently R!=() Post: R = (r0, R') Returns: r0

isEmpty

public boolean isEmpty()
Reports whether or not the list is empty (i.e., contains no items).

Returns:
boolean true iff the list is empty. Pre: none Post: P'==P Returns: L==() && R==()

atFront

public boolean atFront()
Reports whether or not current viewing position is at front of list

Returns:
boolean true iff current position is front Pre: none Post: P'==P Returns: L==()

atRear

public boolean atRear()
Reports whether or not current viewing position is at rear of list

Returns:
boolean true iff current position is rear Pre: none Post: P'==P Returns: R==()

toFront

public void toFront()
Moves current viewing position to front of list Pre: none Post: L'==(), R'==(L, R)


toRear

public void toRear()
Moves current viewing position to rear of list Pre: none Post: L'==(L, R), R'==()


previous

public void previous()
Moves current viewing position one place towards the front, if possible. Pre: L!=() Post: L=(L', l#(L)-1), R'=(l#(L)-1, R)


next

public void next()
Moves current viewing position one object towards the rear, if possible. Pre: R!=() Post: L'==(L, r0), R = (r0, R')


toString

public java.lang.String toString()
Return a string representation of a positonal list. The format of the string is "Ofront\t...\tOrear"

Returns:
The string representation of the list

factory

public PositionalList factory()
Returns an empty PositionalList implementation of the type used in the method's application. This method may be required to construct an object of the correct class during complex type extensions

Returns:
An empty object of the implementaiton's class