|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--moka.lang.Object | +--moka.util.LinkedList
The LinkedList
class implements doubly-linked
list. Like an array, it contains components that can be
accessed using an integer index. However, the size of a
LinkedList
can grow or shrink as needed to accommodate
adding and removing items after the LinkedList
has been created.
Each linked lists tries to optimize storage management by reallocating memory every time the size of the array grows or shrinks.
Field Summary | |
int |
size
The actual size of the LinkedList. |
Constructor Summary | |
LinkedList()
Creates a new LinkedList. |
|
LinkedList(moka.util.Enumeration enu)
Creates a new LinkedList adding the elements of the specified enumeration. |
Method Summary | |
void |
add(int index,
moka.lang.Object o)
Inserts the specified element at the specified position in this linked list. |
void |
clear()
Removes all of the elements from this linked list. |
boolean |
contains(moka.lang.Object o)
Returns true if this linked list contains the specified element. |
void |
copyInto(moka.lang.Object[] anArray,
int fromIndex,
int toIndex)
Copies the components of this linked list into the specified array. |
moka.lang.Object |
dequeue()
Removes the object at the beginning of this queue and returns that object as the value of this function. |
moka.util.Enumeration |
elements()
Returns an enumeration of the components of this LinkedList. |
void |
enqueue(moka.lang.Object item)
Enqueues an item at the end of this queue. |
void |
finalize()
Frees the memory used by this object. |
moka.lang.Object |
get(int index)
Returns the element at the specified position in this linked list. |
int |
indexOf(moka.lang.Object o)
Returns the index in this linked list of the first occurrence of the specified element, or -1 if this list does not contain this element. |
int |
indexOf(moka.lang.Object elem,
int index)
Searches for the first occurence of the given argument, beginning the search at index . |
int |
lastIndexOf(moka.lang.Object o)
Returns the index in this linked list of the last occurrence of the specified element, or -1 if this list does not contain this element. |
int |
lastIndexOf(moka.lang.Object elem,
int index)
Searches backwards for the specified object, starting from the specified index, and returns an index to it. |
moka.lang.Object |
peek()
Looks at the object at the top of this stack without removing it from the stack. |
moka.lang.Object |
pop()
Removes the object at the top of this stack and returns that object as the value of this function. |
void |
push(moka.lang.Object item)
Pushes an item onto the top of this stack. |
moka.lang.Object |
remove(int index)
Removes the element at the specified position in this linked list. |
boolean |
remove(moka.lang.Object o)
Removes the first occurrence in this linked list of the specified element. |
moka.lang.Object |
set(int index,
moka.lang.Object element)
Replaces the element at the specified position in this linked list with the specified element. |
java.lang.String |
toString()
Returns a string representation of this LinkedList, containing the String representation of each element. |
Methods inherited from class moka.lang.Object |
equals, getClassName |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int size
Constructor Detail |
public LinkedList()
public LinkedList(moka.util.Enumeration enu)
Method Detail |
public moka.util.Enumeration elements()
public void add(int index, moka.lang.Object o)
index
- index at which the specified element is to be inserted.public void push(moka.lang.Object item)
item
- the item to be pushed onto this stack.public void enqueue(moka.lang.Object item)
item
- the item to be enqueued.public void clear()
public void finalize()
finalize
in class Object
public boolean contains(moka.lang.Object o)
o
- element whose presence in this linked list is to be tested.
public moka.lang.Object get(int index)
index
- index of element to return.
public int indexOf(moka.lang.Object o)
o
- element to search for.
public int lastIndexOf(moka.lang.Object o)
o
- element to search for.
public moka.lang.Object remove(int index)
index
- the index of the element to removed.
public boolean remove(moka.lang.Object o)
o
- element to be removed from this linked list, if present.
public moka.lang.Object peek()
public moka.lang.Object pop()
public moka.lang.Object dequeue()
public moka.lang.Object set(int index, moka.lang.Object element)
index
- index of element to replace.element
- element to be stored at the specified position.
public void copyInto(moka.lang.Object[] anArray, int fromIndex, int toIndex)
anArray
- the array into which the components get copied.fromIndex
- the index of the first object in the linked list
to copy.toIndex
- the index after the last object in the linked list
to copy.public int indexOf(moka.lang.Object elem, int index)
index
.
elem
- an object.index
- the index to start searching from.
index
or later in the
vector or -1
if the object is not
found.public int lastIndexOf(moka.lang.Object elem, int index)
elem
- the desired component.index
- the index to start searching from.
index
in
the linked list or return -1
if the object is not found.public java.lang.String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |