Class ElementOrder<V>
java.lang.Object
org.jgrapht.graph.guava.ElementOrder<V>
- All Implemented Interfaces:
Serializable
Helper class to maintain a total order for a set of elements.
The user can choose between using a comparator, using the natural ordering of the elements or maintaining internally a mapping to long integers. In the latter case the user is also responsible for notifying this class whenever elements are removed, in order to cleanup any internal state. Construction of elements is performed in a lazy manner.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateElementOrder(Comparator<V> comparator, Map<V, Long> indices) Create a new element order. -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> ElementOrder<V> comparator(Comparator<V> comparator) Create an element order with a comparatorintCompare two elementsprivate longcomputeNextId(V vertex) static <V> ElementOrder<V> internal()Create an internal element order which maintains a map from elements to long values.Get the minimum of two elements.static <V> ElementOrder<V> natural()Create an element order with the natural orderingvoidnotifyAddition(V v) Notify about a new element.voidnotifyRemoval(V v) Notify about an element being removed.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
comparator
-
indices
-
nextId
private long nextId
-
-
Constructor Details
-
ElementOrder
Create a new element order.- Parameters:
comparator- the comparator to useindices- internal map from elements to long indices
-
-
Method Details
-
comparator
Create an element order with a comparator- Type Parameters:
V- the element type- Parameters:
comparator- the comparator- Returns:
- the element order
-
natural
Create an element order with the natural ordering- Type Parameters:
V- the element type- Returns:
- the element order
-
internal
Create an internal element order which maintains a map from elements to long values.- Type Parameters:
V- the element type- Returns:
- the element order
-
compare
-
min
-
notifyAddition
-
notifyRemoval
Notify about an element being removed. This method only affects the case that an internal map to long integers is maintained.- Parameters:
v- the element
-
computeNextId
-