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 $

Inner Class Summary
(package private)  class ModelList.Iterator
          Iterators for model list.
private static class ModelList.Node
          A node class for the list.
 
Field Summary
private  ModelList.Node _head
           
private  int _length
          keep track of length for constant time length lookup
private  Set _listeners
          a set of objects that can trigger and listen for updates to the list
private  ModelList.Node _tail
           
 
Constructor Summary
(package private) ModelList()
          Constructor.
 
Method Summary
private  void addListener(Object thing)
           
 ModelList.Iterator getIterator()
          Create a new iterator for this list.
private  void insert(ModelList.Node point, Object item)
          Insert an item before a certain node in the list.
 void insertFront(Object item)
           
 boolean isEmpty()
          Returns true if the list is empty.
 int length()
           
 int listenerCount()
           
private  void remove(ModelList.Node point)
          Remove a node from the list.
private  void removeListener(Object thing)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

_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
Constructor Detail

ModelList

ModelList()
Constructor. Initializes the head and tail nodes, as well as the listener table and the length variable.
Method Detail

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.