ps4
Class Pipe
java.lang.Object
ps4.Pipe
- All Implemented Interfaces:
- Simulatable
- Direct Known Subclasses:
- IntPipe
- public abstract class Pipe
- extends Object
- implements Simulatable
The Pipe abstract class is implemented by each of the pipes in the
pipe-and-filter simulation.
- Specification Fields
-
-
inputQueue : list(object)
-
outputQueue : list(object)
-
label : Object
-
simulator : Simulator (the simulator that contains this
Pipe)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
inQueue
protected List inQueue
outQueue
protected List outQueue
label
protected Object label
sim
protected Simulator sim
Pipe
public Pipe(Object label,
Simulator sim)
- Requires:
- label != null, sim != null
- Effects:
- constructs a new Pipe with the given label and
simulator
checkRep
public void checkRep()
inject
public void inject(Object o)
- Inject an object into the pipe.
- Requires:
- o != null
- Effects:
- Adds o to the end of the input queue of the pipe.
- Modifies:
- this
extract
public Object extract()
- Extract an object from the pipe.
- Requires:
- At least one element is in the output queue.
- Effects:
- Removes the first element from the output queue.
- Modifies:
- this
- Returns:
- The first element from the output queue of the pipe.
outputAvailable
public boolean outputAvailable()
- Check if any output is available from the pipe
- Requires:
- none
- Returns:
- true output is available; i.e. if the output queue
contains at least one element.
contentsIterator
public Iterator contentsIterator()
- Obtain an iterator over the contents of the pipe
- Requires:
- none
- Effects:
- returns an unmodifiable iterator over the list of
elements in this pipe, in both the output and input queues,
starting with the one that will be output next, and ending
with the one most recently input.