Interface SortedPair<K extends Comparable<K>>

Type Parameters:
K - the type of the elements.
All Superinterfaces:
Pair<K,​K>
All Known Subinterfaces:
ByteByteSortedPair, CharCharSortedPair, DoubleDoubleSortedPair, FloatFloatSortedPair, IntIntSortedPair, LongLongSortedPair, ShortShortSortedPair
All Known Implementing Classes:
ByteByteImmutableSortedPair, CharCharImmutableSortedPair, DoubleDoubleImmutableSortedPair, FloatFloatImmutableSortedPair, IntIntImmutableSortedPair, LongLongImmutableSortedPair, ObjectObjectImmutableSortedPair, ShortShortImmutableSortedPair

public interface SortedPair<K extends Comparable<K>>
extends Pair<K,​K>
A pair of sorted elements.

This interface strengthen Pair, without adding methods. It assumes that both elements of the pair are of the same type, and that they are primitive or comparable. It guarantees that the left element is smaller than or equal to the right element.

Implementations of this class can be used to represent unordered pairs by canonicalization. Note that, in particular, if you build a sorted pair using a left and right element in the wrong order they will be exchanged.

  • Method Details

    • of

      static <K extends Comparable<K>> SortedPair<K> of​(K l, K r)
      Returns a new immutable SortedPair with given left and right value.

      Note that if left and right are in the wrong order, they will be exchanged.

      Parameters:
      l - the left value.
      r - the right value.
      Implementation Notes:
      This factory method delegates to ObjectObjectImmutablePair.of(Object, Object).