public class PartialOrderedSet<E>
extends java.util.HashSet<E>
Set with a partial order added to it.| Constructor and Description |
|---|
PartialOrderedSet()
Creates a new empty
PartialOrderedSet. |
PartialOrderedSet(PartialOrderedSet<E> original)
Creates a new partial ordered set with the same elements as
original and the same order. |
| Modifier and Type | Method and Description |
|---|---|
void |
addABeforeB(E a,
E b)
Adds the a < b to the relation.
|
void |
addAll(PartialOrderedSet<? extends E> set)
Adds all elements of the other partial order set.
|
boolean |
allowsABeforeB(E a,
E b)
Tests if the relation allows for a < b.
|
void |
clear() |
boolean |
equals(java.lang.Object obj) |
java.util.List<E> |
getLinearization()
Getter for a linearization of the partial order set.
|
java.util.Map<E,java.util.Set<E>> |
getOrder()
Returns the map containing the forward dependencies defining the order.
|
java.util.List<E> |
getTotalOrder()
Creates a total order of the elements stored in this
PartialOrderedSet. |
java.util.Set<E> |
getTransitiveClosure(E e)
Gets the transitive closure of an element under this relation.
|
java.util.Set<E> |
getTransitiveClosure(java.util.Set<E> subSet)
Gets the transitive closure of a set.
|
int |
hashCode() |
boolean |
isADirectlyBeforeB(E a,
E b)
Tests whether a < b is directly, not just transitively, specified by the
order.
|
boolean |
isReflexive()
Tests whether the relation is reflexive.
|
java.util.Iterator<E> |
iterator() |
void |
merge(PartialOrderedSet<? extends E> set)
If the collection is a
PartialOrderedSet, the order will also be
added. |
boolean |
remove(java.lang.Object e) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
removeIf(java.util.function.Predicate<? super E> filter) |
void |
requireABeforeB(E a,
E b)
Require that A is before b.
|
boolean |
retainAll(java.util.Collection<?> c) |
java.lang.String |
toString() |
public PartialOrderedSet(PartialOrderedSet<E> original)
original and the same order.original - The PartialOrderedSet to copy.public PartialOrderedSet()
PartialOrderedSet.public void addABeforeB(E a, E b)
a - the smaller elementb - the bigger elementjava.lang.IllegalStateException - if b < a is in the relation.public void requireABeforeB(E a, E b)
a - The A which is to be tested.b - The B which is to be tested.public boolean allowsABeforeB(E a, E b)
a - The element that is tested to be allowed before b.b - The element that is tested to be allowed after a.public java.util.Map<E,java.util.Set<E>> getOrder()
public boolean isADirectlyBeforeB(E a, E b)
a - The first element.b - The second element.public java.util.Set<E> getTransitiveClosure(E e)
e - The element of which the transitive closure is asked for.java.lang.NullPointerException - if e is null.public java.util.Set<E> getTransitiveClosure(java.util.Set<E> subSet)
subSet - The set of which the transitive closure is asked for.java.lang.NullPointerException - if subSet is null.public boolean isReflexive()
public java.util.List<E> getTotalOrder()
PartialOrderedSet. The order is created by iterating over all
elements in the set and inserting each element in the list at the position of
the element with the currently smallest index that has to be after the
current element.
If no elements needs to be after the current element, it is appended to the
end. The runtime is O(n²).PartialOrderedSet.public void merge(PartialOrderedSet<? extends E> set)
PartialOrderedSet, the order will also be
added. If the that would destroy asymmetry an IllegalStateException
will be thrown.java.lang.IllegalStateException - if adding the order of another PartialOrderedSet would
destroy asymmetry.public void addAll(PartialOrderedSet<? extends E> set)
set - The set to be added to this partial-order set.public java.lang.String toString()
toString in class java.util.AbstractCollection<E>public java.util.List<E> getLinearization()
public java.util.Iterator<E> iterator()
public void clear()
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public boolean removeIf(java.util.function.Predicate<? super E> filter)
public boolean remove(java.lang.Object e)
public int hashCode()