|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectDoublyLinkedList
public class DoublyLinkedList
This class implements a doubly linked list of characters in Java. The instance variables head and tail are initially null. As elements are added head points to the first element on the list and tail points to the last element. Each node on the list is of type DoubleNode. Each DoubleNode holds a pointer to the previous node and a pointer to the next node in the list.
Constructor Summary | |
---|---|
DoublyLinkedList()
Constructs a new DoublyLinkedList object with head and tail as null. |
Method Summary | |
---|---|
void |
addCharAtEnd(char c)
Add a character node containing the character c to the end of the linked list. |
void |
addCharAtFront(char c)
Add a character node containing the character c to the front of the linked list. |
int |
countNodes()
Counts the number of nodes in the list. |
boolean |
deleteChar(char c)
Deletes the first occurence of the character c from the list. |
boolean |
isEmpty()
Returns true if the list is empty false otherwise |
static void |
main(java.lang.String[] a)
|
char |
removeCharAtEnd()
Remove and return the character at the end of the doubly linked list. |
char |
removeCharFromFront()
Remove and return the character at the front of the doubly linked list. |
void |
reverse()
Reverse the list. |
java.lang.String |
toString()
Returns the list as a String. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DoublyLinkedList()
Method Detail |
---|
public boolean isEmpty()
public void addCharAtEnd(char c)
c
- -- a single characterpublic void addCharAtFront(char c)
c
- -- a single characterpublic char removeCharFromFront()
public char removeCharAtEnd()
public int countNodes()
public boolean deleteChar(char c)
c
- -- the character to be searched for.
public java.lang.String toString()
toString
in class java.lang.Object
public void reverse()
public static void main(java.lang.String[] a)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |