Class ElementOrder<T>

java.lang.Object
com.google.common.graph.ElementOrder<T>

@Beta public final class ElementOrder<T> extends Object
Used to represent the order of elements in a data structure that supports different options for iteration order guarantees.

Example usage:


 MutableGraph<Integer> graph =
     GraphBuilder.directed().nodeOrder(ElementOrder.<Integer>natural()).build();
 
Since:
20.0
  • Method Details

    • unordered

      public static <S> ElementOrder<S> unordered()
      Returns an instance which specifies that no ordering is guaranteed.
    • insertion

      public static <S> ElementOrder<S> insertion()
      Returns an instance which specifies that insertion ordering is guaranteed.
    • natural

      public static <S extends Comparable<? super S>> ElementOrder<S> natural()
      Returns an instance which specifies that the natural ordering of the elements is guaranteed.
    • sorted

      public static <S> ElementOrder<S> sorted(Comparator<S> comparator)
      Returns an instance which specifies that the ordering of the elements is guaranteed to be determined by comparator.
    • type

      public ElementOrder.Type type()
      Returns the type of ordering used.
    • comparator

      public Comparator<T> comparator()
      Returns the Comparator used.
      Throws:
      UnsupportedOperationException - if comparator is not defined
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object