displayablecollections
Class DisplayableLinkedList<E>

java.lang.Object
  extended by java.util.Observable
      extended by displayablecollections.DisplayableLinkedList<E>
All Implemented Interfaces:
DisplayableCollection<E>, DisplayableList<E>, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.Queue<E>

public class DisplayableLinkedList<E>
extends java.util.Observable
implements java.util.Queue<E>, java.lang.Cloneable, java.io.Serializable

A Displayable ArrayList encapsulates a LinkedList and allows it to be displayed by a JList

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface displayablecollections.DisplayableList
DisplayableList.ListChangedNotification<E>
 
Nested classes/interfaces inherited from interface displayablecollections.DisplayableCollection
DisplayableCollection.CollectionChangedNotification<E>
 
Constructor Summary
DisplayableLinkedList()
          Constructs a new empty list
DisplayableLinkedList(java.util.Collection<? extends E> c)
          Constructs a new list containing the elements in the specified collection
 
Method Summary
 boolean add(E o)
           
 void add(int index, E element)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 boolean addAll(int index, java.util.Collection<? extends E> c)
           
 void addFirst(E o)
           
 void addLast(E o)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 E element()
           
 boolean equals(java.lang.Object o)
           
 E get(int index)
           
 E getFirst()
           
 E getLast()
           
 int hashCode()
           
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator<E> listIterator()
           
 java.util.ListIterator<E> listIterator(int index)
           
 javax.swing.ListModel listModel()
          Create a list model for displaying this collection in a JList.
 boolean offer(E o)
           
 javax.swing.ListModel orderedListModel()
          Create a list model for displaying this collection in a JList.
 E peek()
           
 E poll()
           
 E remove()
           
 E remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 E removeFirst()
           
 E removeLast()
           
 boolean retainAll(java.util.Collection<?> c)
           
 E set(int index, E element)
           
 int size()
           
 java.util.List<E> subList(int fromIndex, int toIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Queue
add
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface displayablecollections.DisplayableCollection
addObserver, deleteObservers, listModel
 
Methods inherited from interface java.util.List
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

DisplayableLinkedList

public DisplayableLinkedList()
Constructs a new empty list


DisplayableLinkedList

public DisplayableLinkedList(java.util.Collection<? extends E> c)
Constructs a new list containing the elements in the specified collection

Parameters:
c - the collection whose elements are to be placed in the list
Method Detail

addFirst

public void addFirst(E o)

addLast

public void addLast(E o)

element

public E element()
Specified by:
element in interface java.util.Queue<E>

getFirst

public E getFirst()

getLast

public E getLast()

offer

public boolean offer(E o)
Specified by:
offer in interface java.util.Queue<E>

peek

public E peek()
Specified by:
peek in interface java.util.Queue<E>

poll

public E poll()
Specified by:
poll in interface java.util.Queue<E>

remove

public E remove()
Specified by:
remove in interface java.util.Queue<E>

removeFirst

public E removeFirst()

removeLast

public E removeLast()

orderedListModel

public javax.swing.ListModel orderedListModel()
Description copied from interface: DisplayableList
Create a list model for displaying this collection in a JList. The result of calling toString() is what will actually be displayed for each element. The display will show the elements in the same order as they appear in in the list, including the possibility of displaying duplicates.

Specified by:
orderedListModel in interface DisplayableList<E>

add

public boolean add(E o)
Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.List<E>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.List<E>

add

public void add(int index,
                E element)
Specified by:
add in interface java.util.List<E>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.List<E>

get

public E get(int index)
Specified by:
get in interface java.util.List<E>

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List<E>

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List<E>

listIterator

public java.util.ListIterator<E> listIterator()
Specified by:
listIterator in interface java.util.List<E>

listIterator

public java.util.ListIterator<E> listIterator(int index)
Specified by:
listIterator in interface java.util.List<E>

remove

public E remove(int index)
Specified by:
remove in interface java.util.List<E>

set

public E set(int index,
             E element)
Specified by:
set in interface java.util.List<E>

subList

public java.util.List<E> subList(int fromIndex,
                                 int toIndex)
Description copied from interface: DisplayableList
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

The list returned by this method implements the DisplayableList interface to support enabling this list to notify its observers of changes made through the subList; but the subList itself cannot have observers of its own. Attempting to add an observer to the subList will result in an UnsupportedOperation exception.

Specified by:
subList in interface DisplayableList<E>
Specified by:
subList in interface java.util.List<E>
Parameters:
fromIndex - low endpoint (inclusive) of the subList
toIndex - high endpoint (exclusive) of the subList

listModel

public javax.swing.ListModel listModel()
Description copied from interface: DisplayableCollection
Create a list model for displaying this collection in a JList. The result of calling toString() is what will actually be displayed for each element. There will be no necessary connection between the order of display and any order in the collection, since this method can be invoked on any collection implementing this interface. (For collections having an inherent order, orderedListModel can be used instead.)

Specified by:
listModel in interface DisplayableCollection<E>
See Also:
orderedListModel() in DisplayableList and DisplayableSortedSet

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<E>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<E>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<E>
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E>

size

public int size()
Specified by:
size in interface java.util.Collection<E>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E>