Class IntPair


  • public class IntPair
    extends java.lang.Object
    An immutable pair of integers.
    See Also:
    Mapping.iterator()
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static com.google.common.base.Function<IntPair,​java.lang.Integer> LEFT
      Function that returns the left (source) side of a pair.
      static com.google.common.collect.Ordering<IntPair> ORDERING
      Ordering that compares pairs lexicographically: first by their source, then by their target.
      static com.google.common.base.Function<IntPair,​java.lang.Integer> RIGHT
      Function that returns the right (target) side of a pair.
      int source  
      static com.google.common.base.Function<IntPair,​IntPair> SWAP
      Function that swaps source and target fields of an IntPair.
      int target  
    • Constructor Summary

      Constructors 
      Constructor Description
      IntPair​(int source, int target)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      static java.util.List<java.lang.Integer> left​(java.util.List<IntPair> pairs)
      Returns the left side of a list of pairs.
      static IntPair of​(int left, int right)  
      static java.util.List<java.lang.Integer> right​(java.util.List<IntPair> pairs)
      Returns the right side of a list of pairs.
      java.lang.String toString()  
      static java.util.List<IntPair> zip​(java.util.List<? extends java.lang.Number> lefts, java.util.List<? extends java.lang.Number> rights)
      Converts two lists into a list of IntPairs, whose length is the lesser of the lengths of the source lists.
      static java.util.List<IntPair> zip​(java.util.List<? extends java.lang.Number> lefts, java.util.List<? extends java.lang.Number> rights, boolean strict)
      Converts two lists into a list of IntPairs.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SWAP

        public static final com.google.common.base.Function<IntPair,​IntPair> SWAP
        Function that swaps source and target fields of an IntPair.
      • ORDERING

        public static final com.google.common.collect.Ordering<IntPair> ORDERING
        Ordering that compares pairs lexicographically: first by their source, then by their target.
      • LEFT

        public static final com.google.common.base.Function<IntPair,​java.lang.Integer> LEFT
        Function that returns the left (source) side of a pair.
      • RIGHT

        public static final com.google.common.base.Function<IntPair,​java.lang.Integer> RIGHT
        Function that returns the right (target) side of a pair.
      • source

        public final int source
      • target

        public final int target
    • Constructor Detail

      • IntPair

        public IntPair​(int source,
                       int target)
    • Method Detail

      • of

        public static IntPair of​(int left,
                                 int right)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • zip

        public static java.util.List<IntPair> zip​(java.util.List<? extends java.lang.Number> lefts,
                                                  java.util.List<? extends java.lang.Number> rights)
        Converts two lists into a list of IntPairs, whose length is the lesser of the lengths of the source lists.
        Parameters:
        lefts - Left list
        rights - Right list
        Returns:
        List of pairs
      • zip

        public static java.util.List<IntPair> zip​(java.util.List<? extends java.lang.Number> lefts,
                                                  java.util.List<? extends java.lang.Number> rights,
                                                  boolean strict)
        Converts two lists into a list of IntPairs.

        The length of the combined list is the lesser of the lengths of the source lists. But typically the source lists will be the same length.

        Parameters:
        lefts - Left list
        rights - Right list
        strict - Whether to fail if lists have different size
        Returns:
        List of pairs
      • left

        public static java.util.List<java.lang.Integer> left​(java.util.List<IntPair> pairs)
        Returns the left side of a list of pairs.
      • right

        public static java.util.List<java.lang.Integer> right​(java.util.List<IntPair> pairs)
        Returns the right side of a list of pairs.