ptolemy.domains.rendezvous.kernel
Class RendezvousReceiver.TopologicalSort

java.lang.Object
  extended by ptolemy.domains.rendezvous.kernel.RendezvousReceiver.TopologicalSort
Enclosing class:
RendezvousReceiver

private static class RendezvousReceiver.TopologicalSort
extends java.lang.Object

Topological sort for the set of receivers to be committed. The set of receivers may have dependencies among them, because receivers in the up-stream of a Merge or Barrier must be committed before those in the down-stream. This sort takes a set of receivers, and returns one of them at a time in the topological order. Cycles must not exist in the set of receivers; Otherwise, there will be InternalErrorException or infinite loop.

Since:
Ptolemy II 5.1
Version:
$Id: RendezvousReceiver.java,v 1.18 2005/11/03 21:27:29 tfeng Exp $
Author:
Thomas Feng

Field Summary
private  java.util.Set _receivers
          The set of receivers given to the constructor.
private  java.util.Set _zeroInDegree
          The set of receivers with zero in-degree, with can be immediately returned by next().
 
Constructor Summary
RendezvousReceiver.TopologicalSort(java.util.Set receivers)
          Construct a topological sort object with a set of receivers ready to commit.
 
Method Summary
private  void _initialize()
          Initialize the set of zero in-degree receivers.
 boolean hasNext()
          Test whether there are more receiver to be returned.
 Receiver next()
          Return the next receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_receivers

private java.util.Set _receivers
The set of receivers given to the constructor.


_zeroInDegree

private java.util.Set _zeroInDegree
The set of receivers with zero in-degree, with can be immediately returned by next().

Constructor Detail

RendezvousReceiver.TopologicalSort

RendezvousReceiver.TopologicalSort(java.util.Set receivers)
Construct a topological sort object with a set of receivers ready to commit.

Parameters:
receivers - The set of receivers.
Method Detail

hasNext

public boolean hasNext()
Test whether there are more receiver to be returned.

Returns:
true if there are more receiver; false otherwise.

next

public Receiver next()
Return the next receiver. There must be some receiver left.

Returns:
The next receiver.

_initialize

private void _initialize()
Initialize the set of zero in-degree receivers.