NEList.java
Created with JBuilder
package OOscheme;
/**
 * Represents a non-empty list.
 * Implemented as a composite.
 * @author Dung X. Nguyen
 * @version 2.0
 * @since 01/31/02
 * @Custom Copyright 2002 -All rights reserved
 * @stereotype composite
 */
public class NEList extends AList {
    private Object _first;
    /**
     * composite
     */
    private AList _rest;

    /**
     * Initializes this NEList to the given first and rest.
     * @param dat the first data element of this NEList.
     * @param tail != null, the rest of this AList.
     */
    public NEList(Object dat, AList tail) {
        _first = dat;
        _rest = tail;
    }

    /**
    * @return the first element of this NEList.
    */
    public Object getFirst() {
        return _first;
    }

    /**
    * @return the rest of this NEList.
    */
    public AList getRest() {
        return _rest;
    }

    /**
     * Calls algo's non-empty case.
     */
    public Object execute(IListAlgo algo, Object inp) {
        return algo.nonEmptyCase(this, inp);
    }
}



NEList.java
Created with JBuilder