public abstract class TransactionList
extends java.lang.Object
TransactionList
subclasses are immutable, i.e. the objects
cannot be altered after creation. There are two subclasses, which correspond
to the two common constructors NIL (singleton) and CONS of lists.Modifier and Type | Field and Description |
---|---|
static TransactionList |
EMPTY_LIST |
Constructor and Description |
---|
TransactionList() |
Modifier and Type | Method and Description |
---|---|
abstract Transaction |
head() |
abstract boolean |
isEmpty() |
abstract int |
length() |
TransactionList |
prepend(Transaction trans)
Construct a list whose first element is
trans , and whose
tail is this list |
abstract TransactionList |
tail() |
public static final TransactionList EMPTY_LIST
public abstract Transaction head()
this
list, or
null
iff this list is emptypublic abstract TransactionList tail()
this
list, or null
iff this list is
emptypublic abstract boolean isEmpty()
true
iff this
list is emptypublic abstract int length()
public TransactionList prepend(Transaction trans)
trans
, and whose
tail is this
listtrans
- the first element of the new list