Methods Summary |
---|
public boolean | add(java.lang.Object o)Adds an Object to this
PartiallyOrderedSet .
if (nodes.contains(o)) {
return false;
}
DigraphNode node = new DigraphNode(o);
poNodes.put(o, node);
return true;
|
public void | clear()
poNodes.clear();
|
public boolean | contains(java.lang.Object o)
return nodes.contains(o);
|
public boolean | hasOrdering(java.lang.Object preferred, java.lang.Object other)Returns true if an ordering exists between two
nodes.
DigraphNode preferredPONode =
(DigraphNode)poNodes.get(preferred);
DigraphNode otherPONode =
(DigraphNode)poNodes.get(other);
return preferredPONode.hasEdge(otherPONode);
|
public java.util.Iterator | iterator()Returns an iterator over the elements contained in this
collection, with an ordering that respects the orderings set
by the setOrdering method.
return new PartialOrderIterator(poNodes.values().iterator());
|
public boolean | remove(java.lang.Object o)Removes an Object from this
PartiallyOrderedSet .
DigraphNode node = (DigraphNode)poNodes.get(o);
if (node == null) {
return false;
}
poNodes.remove(o);
node.dispose();
return true;
|
public boolean | setOrdering(java.lang.Object first, java.lang.Object second)Sets an ordering between two nodes. When an iterator is
requested, the first node will appear earlier in the
sequence than the second node. If a prior ordering existed
between the nodes in the opposite order, it is removed.
DigraphNode firstPONode =
(DigraphNode)poNodes.get(first);
DigraphNode secondPONode =
(DigraphNode)poNodes.get(second);
secondPONode.removeEdge(firstPONode);
return firstPONode.addEdge(secondPONode);
|
public int | size()
return nodes.size();
|
public boolean | unsetOrdering(java.lang.Object first, java.lang.Object second)Removes any ordering between two nodes.
DigraphNode firstPONode =
(DigraphNode)poNodes.get(first);
DigraphNode secondPONode =
(DigraphNode)poNodes.get(second);
return firstPONode.removeEdge(secondPONode) ||
secondPONode.removeEdge(firstPONode);
|