< prev index next >

src/java.desktop/share/classes/javax/imageio/spi/PartiallyOrderedSet.java

Print this page

        

*** 31,50 **** import java.util.LinkedList; import java.util.Map; import java.util.Set; /** ! * A set of <code>Object</code>s with pairwise orderings between them. ! * The <code>iterator</code> method provides the elements in * topologically sorted order. Elements participating in a cycle * are not returned. * ! * Unlike the <code>SortedSet</code> and <code>SortedMap</code> * interfaces, which require their elements to implement the ! * <code>Comparable</code> interface, this class receives ordering ! * information via its <code>setOrdering</code> and ! * <code>unsetPreference</code> methods. This difference is due to * the fact that the relevant ordering between elements is unlikely to * be inherent in the elements themselves; rather, it is set * dynamically accoring to application policy. For example, in a * service provider registry situation, an application might allow the * user to set a preference order for service provider objects --- 31,50 ---- import java.util.LinkedList; import java.util.Map; import java.util.Set; /** ! * A set of {@code Object}s with pairwise orderings between them. ! * The {@code iterator} method provides the elements in * topologically sorted order. Elements participating in a cycle * are not returned. * ! * Unlike the {@code SortedSet} and {@code SortedMap} * interfaces, which require their elements to implement the ! * {@code Comparable} interface, this class receives ordering ! * information via its {@code setOrdering} and ! * {@code unsetPreference} methods. This difference is due to * the fact that the relevant ordering between elements is unlikely to * be inherent in the elements themselves; rather, it is set * dynamically accoring to application policy. For example, in a * service provider registry situation, an application might allow the * user to set a preference order for service provider objects
*** 62,72 **** // The set of Objects private Set<E> nodes = poNodes.keySet(); /** ! * Constructs a <code>PartiallyOrderedSet</code>. */ public PartiallyOrderedSet() {} public int size() { return nodes.size(); --- 62,72 ---- // The set of Objects private Set<E> nodes = poNodes.keySet(); /** ! * Constructs a {@code PartiallyOrderedSet}. */ public PartiallyOrderedSet() {} public int size() { return nodes.size();
*** 77,95 **** } /** * Returns an iterator over the elements contained in this * collection, with an ordering that respects the orderings set ! * by the <code>setOrdering</code> method. */ public Iterator<E> iterator() { return new PartialOrderIterator<>(poNodes.values().iterator()); } /** ! * Adds an <code>Object</code> to this ! * <code>PartiallyOrderedSet</code>. */ public boolean add(E o) { if (nodes.contains(o)) { return false; } --- 77,95 ---- } /** * Returns an iterator over the elements contained in this * collection, with an ordering that respects the orderings set ! * by the {@code setOrdering} method. */ public Iterator<E> iterator() { return new PartialOrderIterator<>(poNodes.values().iterator()); } /** ! * Adds an {@code Object} to this ! * {@code PartiallyOrderedSet}. */ public boolean add(E o) { if (nodes.contains(o)) { return false; }
*** 98,109 **** poNodes.put(o, node); return true; } /** ! * Removes an <code>Object</code> from this ! * <code>PartiallyOrderedSet</code>. */ public boolean remove(Object o) { DigraphNode<E> node = poNodes.get(o); if (node == null) { return false; --- 98,109 ---- poNodes.put(o, node); return true; } /** ! * Removes an {@code Object} from this ! * {@code PartiallyOrderedSet}. */ public boolean remove(Object o) { DigraphNode<E> node = poNodes.get(o); if (node == null) { return false;
*** 122,133 **** * 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. * ! * @return <code>true</code> if no prior ordering existed ! * between the nodes, <code>false</code>otherwise. */ public boolean setOrdering(E first, E second) { DigraphNode<E> firstPONode = poNodes.get(first); DigraphNode<E> secondPONode = poNodes.get(second); --- 122,133 ---- * 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. * ! * @return {@code true} if no prior ordering existed ! * between the nodes, {@code false} otherwise. */ public boolean setOrdering(E first, E second) { DigraphNode<E> firstPONode = poNodes.get(first); DigraphNode<E> secondPONode = poNodes.get(second);
*** 147,157 **** return firstPONode.removeEdge(secondPONode) || secondPONode.removeEdge(firstPONode); } /** ! * Returns <code>true</code> if an ordering exists between two * nodes. */ public boolean hasOrdering(E preferred, E other) { DigraphNode<E> preferredPONode = poNodes.get(preferred); DigraphNode<E> otherPONode = poNodes.get(other); --- 147,157 ---- return firstPONode.removeEdge(secondPONode) || secondPONode.removeEdge(firstPONode); } /** ! * Returns {@code true} if an ordering exists between two * nodes. */ public boolean hasOrdering(E preferred, E other) { DigraphNode<E> preferredPONode = poNodes.get(preferred); DigraphNode<E> otherPONode = poNodes.get(other);
< prev index next >