CITS2200
Class ListLinked

java.lang.Object
  extended by CITS2200.ListLinked
All Implemented Interfaces:
List

public class ListLinked
extends Object
implements List

Singly linked implementation of a List ADT


Constructor Summary
ListLinked()
          create a new list
 
Method Summary
 void afterLast(WindowLinked w)
          put a window over after-last position
 void beforeFirst(WindowLinked w)
          put a window over before-first position
 Object delete(WindowLinked w)
          delete and return the object under a window, and place window over the next item
 Object examine(WindowLinked w)
          examine the object under a window
 void insertAfter(Object e, WindowLinked w)
          insert an item after a window
 void insertBefore(Object e, WindowLinked w)
          insert an item before a window
 boolean isAfterLast(WindowLinked w)
          check if the window is over the after-last position
 boolean isBeforeFirst(WindowLinked w)
          check if the window is over the before-first position
 boolean isEmpty()
          check if the list is empty
 void next(WindowLinked w)
          move a window to the next position
 void previous(WindowLinked w)
          move a window to the previous position
 Object replace(Object e, WindowLinked w)
          replace the object under a window
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListLinked

public ListLinked()
create a new list

Method Detail

isEmpty

public boolean isEmpty()
check if the list is empty

Specified by:
isEmpty in interface List
Returns:
true if the list is empty, false otherwise

isBeforeFirst

public boolean isBeforeFirst(WindowLinked w)
check if the window is over the before-first position

Specified by:
isBeforeFirst in interface List
Parameters:
w - the window
Returns:
true if the window is over before-first, false otherwise

isAfterLast

public boolean isAfterLast(WindowLinked w)
check if the window is over the after-last position

Specified by:
isAfterLast in interface List
Parameters:
w - the window
Returns:
true if the window is over after-last, false otherwise

beforeFirst

public void beforeFirst(WindowLinked w)
put a window over before-first position

Specified by:
beforeFirst in interface List
Parameters:
w - the window to place

afterLast

public void afterLast(WindowLinked w)
put a window over after-last position

Specified by:
afterLast in interface List
Parameters:
w - the window to place

next

public void next(WindowLinked w)
          throws OutOfBounds
move a window to the next position

Specified by:
next in interface List
Parameters:
w - the window
Throws:
OutOfBounds - if the window is past the end of the list

previous

public void previous(WindowLinked w)
              throws OutOfBounds
move a window to the previous position

Specified by:
previous in interface List
Parameters:
w - the window
Throws:
OutOfBounds - if the window is before the start of the list

insertAfter

public void insertAfter(Object e,
                        WindowLinked w)
                 throws OutOfBounds
insert an item after a window

Specified by:
insertAfter in interface List
Parameters:
e - the item to insert
w - the window
Throws:
OutOfBounds - if the window is past the end of the list

insertBefore

public void insertBefore(Object e,
                         WindowLinked w)
                  throws OutOfBounds
insert an item before a window

Specified by:
insertBefore in interface List
Parameters:
e - the item to insert
w - the window
Throws:
OutOfBounds - if the window is before the start of the list

examine

public Object examine(WindowLinked w)
               throws OutOfBounds
examine the object under a window

Specified by:
examine in interface List
Parameters:
w - the window
Returns:
the object under the window
Throws:
OutOfBounds - if the window is outside the list

replace

public Object replace(Object e,
                      WindowLinked w)
               throws OutOfBounds
replace the object under a window

Specified by:
replace in interface List
Parameters:
e - the new object
w - the window
Returns:
the object previously under the window
Throws:
OutOfBounds - if the window is outside the list

delete

public Object delete(WindowLinked w)
              throws OutOfBounds
delete and return the object under a window, and place window over the next item

Specified by:
delete in interface List
Parameters:
w - the window
Returns:
the object previously under the window
Throws:
OutOfBounds - if the window is outside the list