Package org.apache.calcite.util.mapping
Class IntPair
- java.lang.Object
-
- org.apache.calcite.util.mapping.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 anIntPair
.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 ofIntPair
s, 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 ofIntPair
s.
-
-
-
Field Detail
-
SWAP
public static final com.google.common.base.Function<IntPair,IntPair> SWAP
Function that swaps source and target fields of anIntPair
.
-
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
-
-
Method Detail
-
of
public static IntPair of(int left, int right)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.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 ofIntPair
s, whose length is the lesser of the lengths of the source lists.- Parameters:
lefts
- Left listrights
- 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 ofIntPair
s.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 listrights
- Right liststrict
- 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.
-
-