LList
antlr.collections.impl
Class LList
java.lang.Object
antlr.collections.impl.LList
- All Implemented Interfaces:
- List, Stack
- public class LList
- extends java.lang.Object
- implements List, Stack
A Linked List Implementation (not thread-safe for simplicity)
(adds to the tail) (has an enumeration)
|
Constructor Summary |
LList()
|
|
Method Summary |
void |
add(java.lang.Object o)
Add an object to the end of the list. |
void |
append(java.lang.Object o)
Append an object to the end of the list. |
java.lang.Object |
elementAt(int i)
Get the ith element in the list. |
java.util.Enumeration |
elements()
Return an enumeration of the list elements |
int |
height()
How high is the stack? |
boolean |
includes(java.lang.Object o)
Answers whether or not an object is contained in the list |
int |
length()
Return the length of the list. |
java.lang.Object |
pop()
Pop the top element of the stack off. |
void |
push(java.lang.Object o)
Push an object onto the stack. |
java.lang.Object |
top()
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LList
public LList()
add
public void add(java.lang.Object o)
- Add an object to the end of the list.
- Specified by:
add in interface List
- Parameters:
o - the object to add
append
public void append(java.lang.Object o)
- Append an object to the end of the list.
- Specified by:
append in interface List
- Parameters:
o - the object to append
elementAt
public java.lang.Object elementAt(int i)
throws java.util.NoSuchElementException
- Get the ith element in the list.
- Specified by:
elementAt in interface 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
- Throws:
java.util.NoSuchElementException
elements
public java.util.Enumeration elements()
- Return an enumeration of the list elements
- Specified by:
elements in interface List
height
public int height()
- How high is the stack?
- Specified by:
height in interface Stack
includes
public boolean includes(java.lang.Object o)
- Answers whether or not an object is contained in the list
- Specified by:
includes in interface List
- Parameters:
o - the object to test for inclusion.
- Returns:
- true if object is contained else false.
length
public int length()
- Return the length of the list.
- Specified by:
length in interface List
pop
public java.lang.Object pop()
throws java.util.NoSuchElementException
- Pop the top element of the stack off.
- Specified by:
pop in interface Stack
- Returns:
- the top of stack that was popped off.
- Throws:
java.util.NoSuchElementException - if the stack is empty.
push
public void push(java.lang.Object o)
- Push an object onto the stack.
- Specified by:
push in interface Stack
- Parameters:
o - the object to push
top
public java.lang.Object top()
throws java.util.NoSuchElementException
- Specified by:
top in interface Stack
- Throws:
java.util.NoSuchElementException