antlr.collections.impl

Class LList

public class LList extends Object implements List, Stack

A Linked List Implementation (not thread-safe for simplicity) (adds to the tail) (has an enumeration)
Field Summary
protected LLCellhead
protected intlength
protected LLCelltail
Method Summary
voidadd(Object o)
Add an object to the end of the list.
voidappend(Object o)
Append an object to the end of the list.
protected ObjectdeleteHead()
Delete the object at the head of the list.
ObjectelementAt(int i)
Get the ith element in the list.
Enumerationelements()
Return an enumeration of the list elements
intheight()
How high is the stack?
booleanincludes(Object o)
Answers whether or not an object is contained in the list
protected voidinsertHead(Object o)
Insert an object at the head of the list.
intlength()
Return the length of the list.
Objectpop()
Pop the top element of the stack off.
voidpush(Object o)
Push an object onto the stack.
Objecttop()

Field Detail

head

protected LLCell head

length

protected int length

tail

protected LLCell tail

Method Detail

add

public void add(Object o)
Add an object to the end of the list.

Parameters: o the object to add

append

public void append(Object o)
Append an object to the end of the list.

Parameters: o the object to append

deleteHead

protected Object deleteHead()
Delete the object at the head of the list.

Returns: the object found at the head of the list.

Throws: NoSuchElementException if the list is empty.

elementAt

public Object elementAt(int i)
Get the ith element in the list.

Parameters: i the index (from 0) of the requested element.

Returns: the object at index i NoSuchElementException is thrown if i out of range

elements

public Enumeration elements()
Return an enumeration of the list elements

height

public int height()
How high is the stack?

includes

public boolean includes(Object o)
Answers whether or not an object is contained in the list

Parameters: o the object to test for inclusion.

Returns: true if object is contained else false.

insertHead

protected void insertHead(Object o)
Insert an object at the head of the list.

Parameters: o the object to add

length

public int length()
Return the length of the list.

pop

public Object pop()
Pop the top element of the stack off.

Returns: the top of stack that was popped off.

Throws: NoSuchElementException if the stack is empty.

push

public void push(Object o)
Push an object onto the stack.

Parameters: o the object to push

top

public Object top()