|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--LinkList
LinkList.java
Illustrates the implementation of a linked list.
Based on Linked List
Created: Thu Feb 20 20:14:03 2003
| Constructor Summary | |
LinkList(Object f)
Creates a new LinkList containing one Object. |
|
LinkList(Object f,
LinkList list)
Creates a new LinkList consisting of an Object
prepended to another list. |
|
| Method Summary | |
boolean |
add(Object o)
Appends the specified element to the end of this list. |
Object |
get(int index)
Returns the element at the specified position in this list, the first element having index == 1. |
Object |
getFirst()
Returns the first element in this list. |
LinkList |
getRest()
Returns this list omitting the first element. |
LinkList |
insert(Object obj,
int ndx)
Returns a LinkList just like this one, but with
obj inserted as the new
ndxth element. |
Object |
remove(int index)
Removes the element at the specified position (must be between 2 and the size of this list, inclusive) in this list. |
int |
size()
Returns the number of elements in this list. |
String |
toString()
Returns a string representing this list as its elements, separated by commas, surrounded by parentheses. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public LinkList(Object f)
LinkList containing one Object.
f - the Object to be put into this list.
public LinkList(Object f,
LinkList list)
LinkList consisting of an Object
prepended to another list.
f - the Object to be the first element of
this list.list - a LinkList to be the
rest of this list.| Method Detail |
public Object getFirst()
public LinkList getRest()
public Object get(int index)
throws IndexOutOfBoundsException
index - index of element to return.
IndexOutOfBoundsException - if the specified index is
is out of range (index < 1 || index > size()).public int size()
public boolean add(Object o)
o - element to be appended to this list.
public Object remove(int index)
throws IndexOutOfBoundsException
index - the index of the element to removed.
IndexOutOfBoundsException - if the specified index is
out of range (index < 2 || index > size()).
public LinkList insert(Object obj,
int ndx)
LinkList just like this one, but with
obj inserted as the new
ndxth element.
obj - the Object to be inserted.ndx - the new position for obj.
LinkList just like this one, but with
obj inserted as the new
ndxth element.
IndexOutOfBoundsException - if ndx < 1 ||
ndx > this.size()+1.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||