Package antlr.collections.impl
Class LList
java.lang.Object
antlr.collections.impl.LList
A Linked List Implementation (not thread-safe for simplicity)
(adds to the tail) (has an enumeration)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an object to the end of the list.void
Append an object to the end of the list.protected Object
Delete the object at the head of the list.elementAt
(int i) Get the ith element in the list.elements()
Return an enumeration of the list elementsint
height()
How high is the stack?boolean
Answers whether or not an object is contained in the listprotected void
insertHead
(Object o) Insert an object at the head of the list.int
length()
Return the length of the list.pop()
Pop the top element of the stack off.void
Push an object onto the stack.top()
-
Field Details
-
head
-
tail
-
length
protected int length
-
-
Constructor Details
-
LList
public LList()
-
-
Method Details
-
add
Add an object to the end of the list. -
append
Append an object to the end of the list. -
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
Get the ith element in the list.- Specified by:
elementAt
in interfaceList
- Parameters:
i
- the index (from 0) of the requested element.- Returns:
- the object at index i NoSuchElementException is thrown if i out of range
- Throws:
NoSuchElementException
-
elements
Return an enumeration of the list elements -
height
public int height()How high is the stack? -
includes
Answers whether or not an object is contained in the list -
insertHead
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
Pop the top element of the stack off.- Specified by:
pop
in interfaceStack
- Returns:
- the top of stack that was popped off.
- Throws:
NoSuchElementException
- if the stack is empty.
-
push
Push an object onto the stack. -
top
- Specified by:
top
in interfaceStack
- Throws:
NoSuchElementException
-