public final class ElementOrder<T>
extends java.lang.Object
Example usage:
MutableGraph<Integer> graph =
GraphBuilder.directed().nodeOrder(ElementOrder.<Integer>natural()).build();
| Modifier and Type | Class and Description |
|---|---|
static class |
ElementOrder.Type
The type of ordering that this object specifies.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Comparator<T> |
comparator |
private ElementOrder.Type |
type |
| Modifier | Constructor and Description |
|---|---|
private |
ElementOrder(ElementOrder.Type type,
java.util.Comparator<T> comparator) |
| Modifier and Type | Method and Description |
|---|---|
(package private) <T1 extends T> |
cast() |
java.util.Comparator<T> |
comparator()
Returns the
Comparator used. |
(package private) <K extends T,V> |
createMap(int expectedSize)
Returns an empty mutable map whose keys will respect this
ElementOrder. |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
static <S> ElementOrder<S> |
insertion()
Returns an instance which specifies that insertion ordering is guaranteed.
|
static <S extends java.lang.Comparable<? super S>> |
natural()
Returns an instance which specifies that the natural ordering of the elements is guaranteed.
|
static <S> ElementOrder<S> |
sorted(java.util.Comparator<S> comparator)
Returns an instance which specifies that the ordering of the elements is guaranteed to be
determined by
comparator. |
static <S> ElementOrder<S> |
stable()
Returns an instance which specifies that ordering is guaranteed to be always be the same across
iterations, and across releases.
|
java.lang.String |
toString() |
ElementOrder.Type |
type()
Returns the type of ordering used.
|
static <S> ElementOrder<S> |
unordered()
Returns an instance which specifies that no ordering is guaranteed.
|
private final ElementOrder.Type type
@CheckForNull private final java.util.Comparator<T> comparator
private ElementOrder(ElementOrder.Type type, @CheckForNull java.util.Comparator<T> comparator)
public static <S> ElementOrder<S> unordered()
public static <S> ElementOrder<S> stable()
This instance is only useful in combination with incidentEdgeOrder, e.g. graphBuilder.incidentEdgeOrder(ElementOrder.stable()).
incidentEdgeOrderincidentEdgeOrder(ElementOrder.stable()) guarantees the ordering of the returned
collections of the following methods:
Graph and ValueGraph:
edges(): Stable order
adjacentNodes(node): Connecting edge insertion order
predecessors(node): Connecting edge insertion order
successors(node): Connecting edge insertion order
incidentEdges(node): Edge insertion order
Network:
adjacentNodes(node): Stable order
predecessors(node): Connecting edge insertion order
successors(node): Connecting edge insertion order
incidentEdges(node): Stable order
inEdges(node): Edge insertion order
outEdges(node): Edge insertion order
adjacentEdges(edge): Stable order
edgesConnecting(nodeU, nodeV): Edge insertion order
public static <S> ElementOrder<S> insertion()
public static <S extends java.lang.Comparable<? super S>> ElementOrder<S> natural()
public static <S> ElementOrder<S> sorted(java.util.Comparator<S> comparator)
comparator.public ElementOrder.Type type()
public java.util.Comparator<T> comparator()
Comparator used.java.lang.UnsupportedOperationException - if comparator is not definedpublic boolean equals(@CheckForNull
java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object<K extends T,V> java.util.Map<K,V> createMap(int expectedSize)
ElementOrder.<T1 extends T> ElementOrder<T1> cast()