de.cau.cs.kieler.sj.util
Class AbstractCollection<T>

java.lang.Object
  extended by de.cau.cs.kieler.sj.util.AbstractCollection<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
LinkedList, PriorityQueue

public abstract class AbstractCollection<T>
extends Object
implements Iterable<T>

A AbstactCollection as a basic implementation for lists, queues and more.

Rating red

Field Summary
protected  de.cau.cs.kieler.sj.util.ContainerWithLink<T> cursor
          Cursor used to iterate through a collection.
protected  de.cau.cs.kieler.sj.util.ContainerWithLink<T> lastContainer
          The last container of the collection.
protected  de.cau.cs.kieler.sj.util.ContainerWithLink<T> leftSentinel
          The left sentinel of the collection.
protected  int size
          The size of the collection.
 
Constructor Summary
AbstractCollection()
          Creates a empty AbstactCollection.
 
Method Summary
abstract  void add(T o)
          Adds a given element to the collection.
 void clear()
          Deletes all elements of the collection.
 boolean contains(T o)
          Tests if a given element is part of the collection.
 boolean isEmpty()
          Tests if the collection is empty.
 Iterator<T> iterator()
          Gives you an iterator of the collection.
 boolean remove(T o)
          Removes a given element from the collection.
 int size()
          Returns the size of the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftSentinel

protected de.cau.cs.kieler.sj.util.ContainerWithLink<T> leftSentinel
The left sentinel of the collection. Just the container you usually start with itterating the collection.


lastContainer

protected de.cau.cs.kieler.sj.util.ContainerWithLink<T> lastContainer
The last container of the collection.


size

protected int size
The size of the collection.


cursor

protected de.cau.cs.kieler.sj.util.ContainerWithLink<T> cursor
Cursor used to iterate through a collection.

Constructor Detail

AbstractCollection

public AbstractCollection()
Creates a empty AbstactCollection. Because of the reason this class is abstract this is constructor normally used with super().

Method Detail

clear

public void clear()
Deletes all elements of the collection.


iterator

public Iterator<T> iterator()
Gives you an iterator of the collection.

Specified by:
iterator in interface Iterable<T>
Returns:
the iterator of the collection

isEmpty

public boolean isEmpty()
Tests if the collection is empty.

Returns:
true if empty else false.

contains

public boolean contains(T o)
Tests if a given element is part of the collection. For this the method equals is used.

Parameters:
o - The element to test if it is part of the collection.
Returns:
true if the given element is part of the collection else false.

remove

public boolean remove(T o)
Removes a given element from the collection.

Parameters:
o - The element that shoud be removed.
Returns:
Returns true if the element was in the collection and could be removed.

add

public abstract void add(T o)
Adds a given element to the collection.

Parameters:
o - The element to add.

size

public int size()
Returns the size of the collection.

Returns:
The size of the collection.