jInfer

cz.cuni.mff.ksi.jinfer.iss.objects
Class DeletableList<T>

java.lang.Object
  extended by cz.cuni.mff.ksi.jinfer.iss.objects.DeletableList<T>

public class DeletableList<T>
extends Object

Class representing a "list" that can be traversed even as items are removed from it. The iteration should be done using the hasNext() and next() methods. Note that after one pass using these methods the list cannot be traversed anymore.


Constructor Summary
DeletableList(List<T> data)
          Full constructor.
 
Method Summary
 List<T> getLive()
          Returns a list of items that are still "alive" in this object, i.e.
 boolean hasNext()
          Checks whether there are more items to iterate.
 T next()
          Returns the next item of the list.
 void remove(T t)
          Removes all occurences of the specified item from the list.
 void removeAll(Collection<T> c)
          Removes from this object all occurences of all items in the specified collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeletableList

public DeletableList(List<T> data)
Full constructor.

Parameters:
data - List of items this object will represent.
Method Detail

hasNext

public boolean hasNext()
Checks whether there are more items to iterate.

Returns:
true if there are more items to iterate, false otherwise.

next

public T next()
Returns the next item of the list.

Returns:
The next element in the iteration or null if there are no left.

remove

public void remove(T t)
Removes all occurences of the specified item from the list. Uses Object.equals(java.lang.Object) to check for equality.

Parameters:
t - The object to remove.

removeAll

public void removeAll(Collection<T> c)
Removes from this object all occurences of all items in the specified collection. Uses Object.equals(java.lang.Object) to check for equality.

Parameters:
c - Collection containing items to be removed.

getLive

public List<T> getLive()
Returns a list of items that are still "alive" in this object, i.e. those that were not removed.

Returns:
List of all "live" items in this list.

jInfer

Generated on Fri Dec 9 00:01:25 CET 2011