Package uk.ac.starlink.util
Class Pair<T>
- java.lang.Object
-
- uk.ac.starlink.util.Pair<T>
-
public class Pair<T> extends java.lang.Object
Aggregates two objects of the same type. This utility class does not do anything clever.- Since:
- 12 Sep 2019
- Author:
- Mark Taylor
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
T
getItem1()
Returns this pair's first item.T
getItem2()
Returns this item's second item.int
hashCode()
static <S> Pair<S[]>
splitArray(S[] in)
Splits an array into two consituent parts.static <S> Pair<java.util.Collection<S>>
splitCollection(java.util.Collection<S> in)
Splits a collection into two constituent parts.java.lang.String
toString()
-
-
-
Method Detail
-
getItem1
public T getItem1()
Returns this pair's first item.- Returns:
- item
-
getItem2
public T getItem2()
Returns this item's second item.- Returns:
- item
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
splitCollection
public static <S> Pair<java.util.Collection<S>> splitCollection(java.util.Collection<S> in)
Splits a collection into two constituent parts.- Parameters:
in
- input collection; unaffected on exit- Returns:
- pair of non-null collections (currently Lists), each containing about half of the input collection
-
splitArray
public static <S> Pair<S[]> splitArray(S[] in)
Splits an array into two consituent parts.- Parameters:
in
- input array; unaffected on exit- Returns:
- pair of non-null arrays, each containing about half of the input array
-
-