edu.rice.cs.drjava.model.definitions.reducedmodel
Class ModelList
java.lang.Object
|
+--edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList
- Direct Known Subclasses:
- TokenList
- class ModelList
- extends Object
A list class with some extra features.
Allows multiple iterators to make modifications to the same list
without failing like the iterators for java.util.*List.
- Version:
- $Id: ModelList.java,v 1.17 2002/02/08 14:22:21 brianstoler Exp $
Constructor Summary |
(package private) |
ModelList()
Constructor. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
_head
private ModelList.Node _head
_tail
private ModelList.Node _tail
_length
private int _length
- keep track of length for constant time length lookup
_listeners
private Set _listeners
- a set of objects that can trigger and listen for updates to the list
ModelList
ModelList()
- Constructor.
Initializes the head and tail nodes, as well as the listener table
and the length variable.
insert
private void insert(ModelList.Node point,
Object item)
- Insert an item before a certain node in the list.
Can never be called on head node.
insertFront
public void insertFront(Object item)
remove
private void remove(ModelList.Node point)
- Remove a node from the list.
Can't remove head or tail node - exception thrown.
addListener
private void addListener(Object thing)
removeListener
private void removeListener(Object thing)
listenerCount
public int listenerCount()
isEmpty
public boolean isEmpty()
- Returns true if the list is empty.
length
public int length()
getIterator
public ModelList.Iterator getIterator()
- Create a new iterator for this list. The constructor for the
iterator adds itself to the list's listeners. The iterator
must be notified of changes so it does not become out-of-date.