BRUtil - Making Java a Kinder, Gentler, Place to be.

brutil
Class LinkedList

java.lang.Object
  |
  +--brutil.LinkedList
All Implemented Interfaces:
Collection, List, brutil.aspects.ReferenceCountable

public class LinkedList
extends java.lang.Object
implements List, brutil.aspects.ReferenceCountable

SinglyLinkedList implementation - caters to the List interface.


Constructor Summary
LinkedList()
           
 
Method Summary
 void append(java.lang.Object elt)
          Appends given element to the end of the list.
 void clear()
          Removes all elements from the list.
 java.lang.Object getFirst()
          Returns the element at the beginning of the list.
 java.lang.Object getLast()
          Returns the element at the end of the list.
 boolean isEmpty()
          Returns true if there are no elements in the list size == 0.
 ListIterator iterator()
          Returns an ListIterator.
 void prepend(java.lang.Object elt)
          Prepends given element to the beginning of the list.
 java.lang.Object removeFirst()
          Removes and returns the first element in the list.
 java.lang.Object removeLast()
          Removes last element in the list (optional operation).
 LinkedList reset()
           
 ReverseListIterator reverseIterator()
          Creates a ReverseListIterator (optional operation).]
 int size()
          Returns the size of the List.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Method Detail

reset

public LinkedList reset()

prepend

public void prepend(java.lang.Object elt)
Prepends given element to the beginning of the list.
Specified by:
prepend in interface List
Parameters:
elt - the element to be prepended.

append

public void append(java.lang.Object elt)
Appends given element to the end of the list.
Specified by:
append in interface List
Parameters:
elt - the element to be appended.

getFirst

public java.lang.Object getFirst()
Returns the element at the beginning of the list.
Specified by:
getFirst in interface List
Returns:
the element at the beginning of the list.
Throws:
NoSuchElementException - if the list is empty.

getLast

public java.lang.Object getLast()
Returns the element at the end of the list.
Specified by:
getLast in interface List
Returns:
the element at the end of the list.
Throws:
NoSuchElementException - if the list is empty.

removeFirst

public java.lang.Object removeFirst()
Removes and returns the first element in the list.
Specified by:
removeFirst in interface List
Returns:
first element.
Throws:
NoSuchElementException - if the list is empty.

removeLast

public java.lang.Object removeLast()
                            throws java.lang.UnsupportedOperationException
Removes last element in the list (optional operation).
Specified by:
removeLast in interface List
Throws:
java.lang.UnsupportedOperationException -  

size

public int size()
Returns the size of the List.
Specified by:
size in interface List
Returns:
the size of the list.

isEmpty

public boolean isEmpty()
Returns true if there are no elements in the list size == 0.
Specified by:
isEmpty in interface List
Returns:
true if there are no elements in the list size == 0.

clear

public void clear()
Removes all elements from the list.
Specified by:
clear in interface List

iterator

public ListIterator iterator()
Returns an ListIterator.
Specified by:
iterator in interface List

reverseIterator

public ReverseListIterator reverseIterator()
                                    throws java.lang.UnsupportedOperationException
Creates a ReverseListIterator (optional operation).]
Specified by:
reverseIterator in interface List
Throws:
UnsupportedMethodException -  

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


BRUtil - Making Java a Kinder, Gentler, Place to be.