The ObjectList class describes immutable linked lists of objects. An object list is either the empty list or a (non-empty) list node with a head component that is an Object and a tail component that is another object list. The lists are immutable in the sense that the head or tail of a list node cannot be changed after the list node has been created (via the prepend() method).
There are no public constructor or instance methods for integer lists; they are created and manipulated by the following class methods:
Class Methods
public
static
ObjectList
empty()
Returns an empty object list.
public
static
ObjectList
prepend (Object x, ObjectList L)
Returns a new object list node whose head is x
and whose tail is L
.
public
static
boolean
isEmpty
(ObjectList L)
Returns true if
L
is an empty object list and
false if L
is an object list node.
public
static
Object head
(ObjectList L)
Returns the object that is the head component of the object
list node L
. Signals an exception
if L
is empty.
public
static
ObjectList
tail (ObjectList L)
Returns the object list that is the tail component of the
object list node L
. Signals an
exception if L
is empty.