javautils.dispensers
Interface Dispenser

All Known Implementing Classes:
AbstractDispenser

public interface Dispenser

A dispenser, see [Meyer1997], is a Strategy, see [Gamma1995], that decides the order in which elements governed by the dispenser will be processed. Some well known strategies are:

Stack or LIFO
The most recent pushed element will be processed next.
Queue or FIFO
The least recent pushed element will be processed next.
Priority queue
The element with the highest priority will be processed next.
Random permutation
The element to be processed next will be chosen randomly.


Method Summary
 boolean isEmpty()
           return size() == 0;
 boolean notEmpty()
           return !isEmpty();
 java.lang.Object pop()
          Chooses the next element to be processed, removes it from the dispenser, and returns the element.
 void push(java.lang.Object element)
          Adds a new element into the dispenser.
 void pushAll(java.util.Collection c)
          Adds all elements in the collection into the dispenser in the order that the iterator of the collection returns them.
 void pushAll(java.util.Iterator i)
          Adds all elements returned by the iterator into the dispenser in the order that the iterator returns them.
 void pushAllRight(java.util.List l)
          Adds all elements in the list into the dispenser starting from the last element in the list.
 int size()
          Number of elements in the dispenser.
 

Method Detail

isEmpty

public boolean isEmpty()
 return size() == 0;
 


notEmpty

public boolean notEmpty()
 return !isEmpty();
 


size

public int size()

Number of elements in the dispenser.


pop

public java.lang.Object pop()

Chooses the next element to be processed, removes it from the dispenser, and returns the element.


push

public void push(java.lang.Object element)

Adds a new element into the dispenser.


pushAll

public void pushAll(java.util.Collection c)

Adds all elements in the collection into the dispenser in the order that the iterator of the collection returns them.


pushAll

public void pushAll(java.util.Iterator i)

Adds all elements returned by the iterator into the dispenser in the order that the iterator returns them.


pushAllRight

public void pushAllRight(java.util.List l)

Adds all elements in the list into the dispenser starting from the last element in the list.