Package uk.ac.starlink.util

# Class Pair<T>

java.lang.Object
uk.ac.starlink.util.Pair<T>

public class Pair<T> extends Object
Aggregates two objects of the same type. This utility class does not do anything clever.

Since:
  12 Sep 2019
Author:
  Mark Taylor
See Also:
  - `Bi`

## Constructor Summary

Constructors
Constructor
Description
`Pair(T item1, T item2)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(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<Collection<S>>`
`splitCollection(Collection<S> in)`
Splits a collection into two constituent parts.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Pair

public Pair(T item1, T item2)
Constructor.

Parameters:
  `item1` - first item
  `item2` - second item

## Method Details

### 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 class `Object`

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### splitCollection

public static <S> Pair<Collection<S>> splitCollection(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