public final class Tuple extends Object implements Iterable<Object>, HeadTail<Object>, Comparable<Tuple>
A tuple essentially behaves like an immutable array. In Golo, tuples can be created as follows:
# Short syntax let t1 = [1, 2, 3] # Complete collection literal syntax let t2 = tuple[1, 2, 3]
| Constructor and Description |
|---|
Tuple(Object... values)
Creates a new tuple from values.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Tuple other)
Compares this tuple with the specified tuple for order.
|
boolean |
equals(Object o) |
static Tuple |
fromArray(Object[] values)
Helper factory method.
|
Object |
get(int index)
Gets the element at a specified index.
|
int |
hashCode() |
Object |
head()
Returns the first element of the tuple.
|
boolean |
isEmpty()
Checks whether the tuple is empty or not.
|
Iterator<Object> |
iterator()
Creates an iterator over the tuple.
|
int |
size()
Gives the number of elements in this tuple.
|
Tuple |
tail()
Returns a new tuple containg the remaining elements.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic Tuple(Object... values)
values - the tuple values.public static Tuple fromArray(Object[] values)
values - the values as an array.public int size()
public boolean isEmpty()
public Object get(int index)
index - the element index.index.IndexOutOfBoundsException - if the specified index is not valid (negative value or above the size).public Iterator<Object> iterator()
The iterator does not support removal.
public int compareTo(Tuple other)
Returns a negative integer, zero, or a positive integer as this tuple is less than, equal to, or greater than the specified tuple.
Two tuples are compared using the lexicographical (dictionary) order, that is:
[1, 2] < [1, 3] and [2, 5] < [3, 1].
Two tuples are comparable if they have the same size and their elements are pairwise comparable.
compareTo in interface Comparable<Tuple>other - the tuple to be compared.NullPointerException - if the specified tuple is nullClassCastException - if the type of the elements in the specified tuple prevent them from being compared to this tuple elements.IllegalArgumentException - if the specified tuple has a different size than this tuple.public Object head()
Copyright © 2015 Institut National des Sciences Appliquées de Lyon (INSA-Lyon). All rights reserved.