All pastes #981895 Raw Edit

ConsCell

public text v1 · immutable
·published 2008-04-12 02:54 UTC
rendered paste body
/**
*/
public class ConsCell {
	private int head; // the first item in the list
	private ConsCell tail; // rest of the list or null

	public ConsCell(int h, ConsCell t) {
		head = h;
		tail = t;
	}
	
	public int getHead() {
		return head;
	}

	public ConsCell getTail() {
		return tail;
	}

	public void setTail(ConsCell t) {
		tail = t;
	}

	public int length() {
		if (tail == null)
			return 1;
		else
			return 1 + tail.length();
	}
}