Groovy JDK

java.util
Class List

Method Summary
List asImmutable()
A convenience method for creating an immutable list
List asSynchronized()
A convenience method for creating a synchronized List.
boolean equals(Object[] right)
Determines if the contents of this list are equal to the contents of the given array in the same order.
boolean equals(List right)
Compare the contents of two Lists.
Process execute()
Executes the command specified by the String list that is the parameter.
T first()
Returns the first item from the List.
List getAt(Range range)
Support the range subscript operator for a List
List getAt(EmptyRange range)
Support the range subscript operator for a List
List getAt(Collection indices)
Select a List of items from a List using a Collection to identify the indices to be selected.
T getAt(int idx)
Support the subscript operator for a List.
T head()
Returns the first item from the List.
T last()
Returns the last item from the List.
List minus(Collection removeMe)
Create a List composed of the elements of the first list minus the elements of the given collection.
List minus(Object operand)
Create a new List composed of the elements of the first list minus the operand.
Set permutations()
Finds all permutations of a collection.
T pop()
Removes the last item from the List.
boolean push(T value)
Appends an item to the List.
void putAt(int idx, T value)
A helper method to allow lists to work with subscript operators.
void putAt(EmptyRange range, Object value)
A helper method to allow lists to work with subscript operators.
void putAt(EmptyRange range, Collection value)
A helper method to allow lists to work with subscript operators.
void putAt(IntRange range, Collection col)
List subscript assignment operator when given a range as the index and the assignment operand is a collection.
void putAt(IntRange range, Object value)
List subscript assignment operator when given a range as the index.
void putAt(List splice, List values)
A helper method to allow lists to work with subscript operators.
void putAt(List splice, Object value)
A helper method to allow lists to work with subscript operators.
List reverse()
Reverses the list.
List reverseEach(Closure closure)
Iterate over each element of the list in the reverse order.
Set subsequences()
Finds all non-null subsequences of a list.
List tail()
Returns the items from the List excluding the first item.
List transpose()
Adds GroovyCollections#transpose(List) as a method on lists.
 
Method Detail

asImmutable

public List asImmutable()
 
A convenience method for creating an immutable list
Returns:
an immutable List
Since:
1.0
See:
Collections#unmodifiableList.

asSynchronized

public List asSynchronized()
 
A convenience method for creating a synchronized List.
Returns:
a synchronized List
Since:
1.0
See:
Collections#synchronizedList.

equals

public boolean equals(Object[] right)
 
Determines if the contents of this list are equal to the contents of the given array in the same order. This returns false if either collection is null.
Parameters:
right - this Object[] being compared to.
Returns:
true if the contents of both collections are equal
Since:
1.5.0

equals

public boolean equals(List right)
 
Compare the contents of two Lists. Order matters. If numbers exist in the Lists, then they are compared as numbers, for example 2 == 2L. If either list is null, the result is false.
Parameters:
right - the List being compared to..
Returns:
boolean true if the contents of both lists are identical, false otherwise.
Since:
1.0

execute

public Process execute()
 
Executes the command specified by the String list that is the parameter. The first item in the array is the command the others are the parameters. All entries must be Strings. For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder.
Returns:
the Process which has just started for this command line string.
Since:
1.0

first

public T first()
 
Returns the first item from the List.
Returns:
the first item from the List
Since:
1.5.5

getAt

public List getAt(Range range)
 
Support the range subscript operator for a List
Parameters:
range - a Range indicating the items to get.
Returns:
a sublist based on range borders or a new list if range is reversed
Since:
1.0
See:
List#subList.

getAt

public List getAt(EmptyRange range)
 
Support the range subscript operator for a List
Parameters:
range - a Range indicating the items to get.
Returns:
a sublist based on range borders or a new list if range is reversed
Since:
1.0
See:
List#subList.

getAt

public List getAt(Collection indices)
 
Select a List of items from a List using a Collection to identify the indices to be selected.
Parameters:
indices - a Collection of indices.
Returns:
a new list of the values at the given indices
Since:
1.0

getAt

public T getAt(int idx)
 
Support the subscript operator for a List.
Parameters:
idx - an index.
Returns:
the value at the given index
Since:
1.0

head

public T head()
 
Returns the first item from the List.
Returns:
the first item from the List
Since:
1.5.5

last

public T last()
 
Returns the last item from the List.
Returns:
the last item from the List
Since:
1.5.5

minus

public List minus(Collection removeMe)
 
Create a List composed of the elements of the first list minus the elements of the given collection.
Parameters:
removeMe - a Collection of elements to remove.
Returns:
a List with the supplied elements removed
Since:
1.0

minus

public List minus(Object operand)
 
Create a new List composed of the elements of the first list minus the operand.
Parameters:
operand - an element to remove from the list.
Returns:
the resulting List with the operand removed
Since:
1.0

permutations

public Set permutations()
 
Finds all permutations of a collection. E.g. [1, 2, 3].permutations() would be: [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
Returns:
the permutations from the list
Since:
1.7.0

pop

public T pop()
 
Removes the last item from the List. Using add() and pop() is similar to push and pop on a Stack.
Returns:
the item removed from the List
Since:
1.0

push

public boolean push(T value)
 
Appends an item to the List. Synonym for add().
Parameters:
value - element to be appended to this list..
Returns:
true (as per the general contract of the Collection.add method).
Since:
1.5.5

putAt

public void putAt(int idx, T value)
 
A helper method to allow lists to work with subscript operators.
Parameters:
idx - an index.
value - the value to put at the given index.
Since:
1.0

putAt

public void putAt(EmptyRange range, Object value)
 
A helper method to allow lists to work with subscript operators.
Parameters:
range - the (in this case empty) subset of the list to set.
value - the values to put at the given sublist or a Collection of values.
Since:
1.0

putAt

public void putAt(EmptyRange range, Collection value)
 
A helper method to allow lists to work with subscript operators.
Parameters:
range - the (in this case empty) subset of the list to set.
value - the Collection of values.
Since:
1.0
See:
#putAt(List, EmptyRange, Object).

putAt

public void putAt(IntRange range, Collection col)
 
List subscript assignment operator when given a range as the index and the assignment operand is a collection. Example: myList[3..5] = anotherList. Items in the given range are relaced with items from the collection.
Parameters:
range - the subset of the list to set.
col - the collection of values to put at the given sublist.
Since:
1.5.0

putAt

public void putAt(IntRange range, Object value)
 
List subscript assignment operator when given a range as the index. Example: myList[3..5] = newItem. Items in the given range are relaced with the operand. The value operand is always treated as a single value.
Parameters:
range - the subset of the list to set.
value - the value to put at the given sublist.
Since:
1.0

putAt

public void putAt(List splice, List values)
 
A helper method to allow lists to work with subscript operators.
Parameters:
splice - the subset of the list to set.
values - the value to put at the given sublist.
Since:
1.0

putAt

public void putAt(List splice, Object value)
 
A helper method to allow lists to work with subscript operators.
Parameters:
splice - the subset of the list to set.
value - the value to put at the given sublist.
Since:
1.0

reverse

public List reverse()
 
Reverses the list. The result is a new List with the identical contents in reverse order.
Returns:
a reversed List
Since:
1.0

reverseEach

public List reverseEach(Closure closure)
 
Iterate over each element of the list in the reverse order.
Parameters:
closure - a closure to which each item is passed..
Returns:
the original list
Since:
1.5.0

subsequences

public Set subsequences()
 
Finds all non-null subsequences of a list. E.g. [1, 2, 3].subsequences() would be: [[1, 2, 3], [1, 3], [2, 3], [1, 2], [1], [2], [3]]
Returns:
the subsequences from the list
Since:
1.7.0

tail

public List tail()
 
Returns the items from the List excluding the first item.
Returns:
a list without its first element
Since:
1.5.6

transpose

public List transpose()
 
Adds GroovyCollections#transpose(List) as a method on lists.
Returns:
a List of the transposed lists
Since:
1.5.0
See:
GroovyCollections#transpose.

Groovy JDK