Class listFW.NEList


public class NEList
extends Object
implements listFW.IList
Represents non-empty lists. Contains two pieces of data: When a class contains other objects that are isomorphic to itself, this class is called a composite.

Provides concrete code for

Author:
D. X. Nguyen, S. B. Wong

Variable Index

 o _first
The first data element
 o _rest
The rest or "tail" of this NEList

Constructor Index

 o NEList (Object, IList)
Initializes this NEList to a given first and a given rest

Method Index

 o execute (IListAlgo, Object)
Calls the nonEmptyCase method of the IListAlgo parameter, passing to this
 o getFirst ()
Returns the first data element of this NEList
 o getRest ()
Returns the first data element of this NEList

Variables

 o _first
private Object _first
The first data element.

 o _rest
private IList _rest
The rest or "tail" of this NEList. Data Invariant: _rest != null;

Constructors

 o NEList
public  NEList(Object f, IList r)
Initializes this NEList to a given first and a given rest.

Parameters:
f - the first element of this NEList.
r - != null, the rest of this NEList.

Methods

 o getFirst
public final Object getFirst()
Returns the first data element of this NEList. This method is marked as final to prevent all subclasses from overriding it. Finalizing a method also allows the compiler to generate more efficient calling code.

 o getRest
public final IList getRest()
Returns the first data element of this NEList. This method is marked as final to prevent all subclasses from overriding it. Finalizing a method also allows the compiler to generate more efficient calling code.

 o execute
public final Object execute(IListAlgo algo, Object inp)
Calls the nonEmptyCase method of the IListAlgo parameter, passing to this method itself as the host parameter and the given input as the input parameter. This method is marked as final to prevent all subclasses from overriding it. Finalizing a method also allows the compiler to generate more efficient calling code.