APIdia Launch Partner
Top Description Fields Constructors Methods
javax.imageio.spi

pack-priv Class PartiallyOrderedSet<E>

Additional top-level class in compilation unit: PartialOrderIterator.

extends AbstractSet<E>
Class Inheritance
Imports
java.util.AbstractSet, .HashMap, .Iterator, .LinkedList, .Map

A set of Objects with pairwise orderings between them. The iterator method provides the elements in topologically sorted order. Elements participating in a cycle are not returned. Unlike the SortedSet and SortedMap interfaces, which require their elements to implement the Comparable interface, this class receives ordering information via its setOrdering and 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 according 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 supplied by a trusted vendor over those supplied by another.

Field Summary

Modifier and TypeField and Description
private final Map<E, DigraphNode<E>>

Constructor Summary

AccessConstructor and Description
public
PartiallyOrderedSet()

Constructs a PartiallyOrderedSet.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(E o)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds an Object to this PartiallyOrderedSet.

public void
clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Removes all of the elements from this set (optional operation).

public boolean
contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.

public boolean
hasOrdering(E preferred, E other)

Returns true if an ordering exists between two nodes.

public Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements contained in this collection, with an ordering that respects the orderings set by the setOrdering method.

public boolean
remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes an Object from this PartiallyOrderedSet.

public boolean

Returns:

true if no prior ordering existed between the nodes, false otherwise.
setOrdering
(E first, E second)

Sets an ordering between two nodes.

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set (its cardinality).

public boolean

Returns:

true if a prior prefence existed between the nodes.
unsetOrdering
(E first, E second)

Removes any ordering between two nodes.

Inherited from java.util.AbstractSet:
equalshashCoderemoveAll

Field Detail

poNodesback to summary
private final Map<E, DigraphNode<E>> poNodes

Constructor Detail

PartiallyOrderedSetback to summary
public PartiallyOrderedSet()

Constructs a PartiallyOrderedSet.

Method Detail

addback to summary
public boolean add(E o)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds an Object to this PartiallyOrderedSet.

clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Doc from java.util.Set.clear.

Removes all of the elements from this set (optional operation). The set will be empty after this call returns.

containsback to summary
public boolean contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

hasOrderingback to summary
public boolean hasOrdering(E preferred, E other)

Returns true if an ordering exists between two nodes.

iteratorback to summary
public Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements contained in this collection, with an ordering that respects the orderings set by the setOrdering method.

removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes an Object from this PartiallyOrderedSet.

setOrderingback to summary
public boolean setOrdering(E first, E 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.

Returns:boolean

true if no prior ordering existed between the nodes, false otherwise.

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

unsetOrderingback to summary
public boolean unsetOrdering(E first, E second)

Removes any ordering between two nodes.

Returns:boolean

true if a prior prefence existed between the nodes.