Package com.gengoai.tuple
Class Tuple2<K,V>
- java.lang.Object
-
- com.gengoai.tuple.Tuple
-
- com.gengoai.tuple.Tuple2<K,V>
-
- Type Parameters:
K
- the type parameterV
- the type parameter
- All Implemented Interfaces:
Copyable<Tuple>
,Serializable
,Comparable<Tuple>
,Iterable<Object>
,Map.Entry<K,V>
public class Tuple2<K,V> extends Tuple implements Map.Entry<K,V>
The type Tuple 2.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tuple3<T,K,V>
appendLeft(T object)
Appends an item the beginning of the tuple resulting in a new tuple of degree + 1<T> Tuple3<K,V,T>
appendRight(T object)
Appends an item the end of the tuple resulting in a new tuple of degree + 1Object[]
array()
The tuple as an array of objectsTuple2<K,V>
copy()
Makes a copy of this object.int
degree()
The number of items in the tuple<T> T
get(int i)
Gets the ith item of the tuple.K
getKey()
K
getV1()
V
getV2()
V
getValue()
static <K,V>
Tuple2<K,V>of(K key, V value)
Of tuple 2.V
setValue(V value)
Tuple1<V>
shiftLeft()
Shifts the first element of the tuple resulting in a tuple of degree - 1.Tuple1<K>
shiftRight()
Shifts the last element of the tuple resulting in a tuple of degree - 1.String
toString()
-
Methods inherited from class com.gengoai.tuple.Tuple
compareTo, equals, hashCode, iterator, map, mapValues, slice, stream
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
of
public static <K,V> Tuple2<K,V> of(K key, V value)
Of tuple 2.- Type Parameters:
K
- the type parameterV
- the type parameter- Parameters:
key
- the keyvalue
- the value- Returns:
- the tuple 2
-
appendLeft
public <T> Tuple3<T,K,V> appendLeft(T object)
Description copied from class:Tuple
Appends an item the beginning of the tuple resulting in a new tuple of degree + 1- Overrides:
appendLeft
in classTuple
- Type Parameters:
T
- the type parameter- Parameters:
object
- the object being appended- Returns:
- A new tuple of degree + 1 containing the object at the beginning
-
appendRight
public <T> Tuple3<K,V,T> appendRight(T object)
Description copied from class:Tuple
Appends an item the end of the tuple resulting in a new tuple of degree + 1- Overrides:
appendRight
in classTuple
- Type Parameters:
T
- the type parameter- Parameters:
object
- the object being appended- Returns:
- A new tuple of degree + 1 containing the object at the end
-
copy
public Tuple2<K,V> copy()
Description copied from interface:Copyable
Makes a copy of this object.
-
degree
public int degree()
Description copied from class:Tuple
The number of items in the tuple
-
get
public <T> T get(int i)
Description copied from class:Tuple
Gets the ith item of the tuple.
-
getV1
public K getV1()
-
getV2
public V getV2()
-
shiftLeft
public Tuple1<V> shiftLeft()
Description copied from class:Tuple
Shifts the first element of the tuple resulting in a tuple of degree - 1.
-
shiftRight
public Tuple1<K> shiftRight()
Description copied from class:Tuple
Shifts the last element of the tuple resulting in a tuple of degree - 1.- Overrides:
shiftRight
in classTuple
- Returns:
- A new tuple without the shifted element;
-
-