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 false if either collection is null
boolean equals(List right)
Compare the contents of two Lists If numbers exist in the Lists, then they are compared as numbers, for example 2 == 2L is false
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 must be Strings can use java
Object first()
Returns the first item from the List
List getAt(IntRange range)
Support the range subscript operator for a List
List getAt(Collection indices)
Allows a List to be used as the indices to be used on a List
Object getAt(int idx)
Support the subscript operator for a List
Object head()
Returns the first item from the List
Object 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
Object pop()
Removes the last item from the List is similar to push and pop on a Stack
boolean push(Object value)
Appends an item to the List
void putAt(int idx, Object 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(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 range are relaced with items from the collection
void putAt(IntRange range, Object value)
List subscript assignment operator when given a range as the index Example: myList[3 range are relaced with the operand always treated as a single value
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 in reverse order
List reverseEach(Closure closure)
Iterate over each element of the list in the reverse order
List tail()
Returns the items from the List excluding the first item
 
Method Detail

asImmutable

public List asImmutable()
A convenience method for creating an immutable list

Returns:
an immutable List
See:
Collections#unmodifiableList.

asSynchronized

public List asSynchronized()
A convenience method for creating a synchronized List.

Returns:
a synchronized List
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

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.

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.

first

public Object first()
Returns the first item from the List.

Returns:
the first item from the List

getAt

public List getAt(IntRange 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
See:
List#subList.

getAt

public List getAt(Collection indices)
Allows a List to be used as the indices to be used on a List

Parameters:
indices - a Collection of indices.
Returns:
a new list of the values at the given indices

getAt

public Object getAt(int idx)
Support the subscript operator for a List.

Parameters:
idx - an index.
Returns:
the value at the given index

head

public Object head()
Returns the first item from the List.

Returns:
the first item from the List

last

public Object last()
Returns the last item from the List.

Returns:
the last item from the List

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

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

pop

public Object 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

push

public boolean push(Object 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).

putAt

public void putAt(int idx, Object 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.

putAt

public void putAt(EmptyRange range, Object value)
A helper method to allow lists to work with subscript operators.

Parameters:
range - the subset of the list to set.
value - the values to put at the given sublist or a Collection of values.

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.

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.

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.

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.

reverse

public List reverse()
Reverses the list. The result is a new List with the identical contents in reverse order.

Returns:
a reversed List

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

tail

public List tail()
Returns the items from the List excluding the first item.

Returns:
a list without its first element

Groovy JDK