|
Groovy JDK |
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[])
Determines if the contents of this list are equal to the contents of the given array in the same order. |
boolean
|
equals(List)
Compare the contents of two Lists. |
Process
|
execute()
Executes the command specified by the given list. |
Process
|
execute(String[], File)
Executes the command specified by the given list, with the environment defined by envp and under the working directory dir .
|
Process
|
execute(List, File)
Executes the command specified by the given list, with the environment defined by envp and under the working directory dir .
|
Object
|
first()
Returns the first item from the List. |
List
|
getAt(Range)
Support the range subscript operator for a List def list = [1, "a", 4.5, true] assert list[1..2] == ["a", 4.5] |
List
|
getAt(EmptyRange)
Support the range subscript operator for a List def list = [true, 1, 3.4] assert list[0..<0] == [] |
List
|
getAt(Collection)
Select a List of items from a List using a Collection to identify the indices to be selected. |
Object
|
getAt(int)
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)
Create a List composed of the elements of the first list minus every occurrence of elements of the given collection. |
List
|
minus(Object)
Create a new List composed of the elements of the first list minus every occurrence of the operand. |
Set
|
permutations()
Finds all permutations of a collection. |
Object
|
pop()
Removes the last item from the List. |
boolean
|
push(Object)
Appends an item to the List. |
void
|
putAt(int, Object)
A helper method to allow lists to work with subscript operators. |
void
|
putAt(EmptyRange, Object)
A helper method to allow lists to work with subscript operators. |
void
|
putAt(EmptyRange, Collection)
A helper method to allow lists to work with subscript operators. |
void
|
putAt(IntRange, Collection)
List subscript assignment operator when given a range as the index and the assignment operand is a collection. |
void
|
putAt(IntRange, Object)
List subscript assignment operator when given a range as the index. |
void
|
putAt(List, List)
A helper method to allow lists to work with subscript operators. |
void
|
putAt(List, Object)
A helper method to allow lists to work with subscript operators. |
List
|
reverse()
Reverses the list. |
List
|
reverseEach(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 |
---|
public List asImmutable()
public List asSynchronized()
public boolean equals(Object[])
false
if either collection is null
.
assert [1, "a"].equals( [ 1, "a" ] as Object[] )
right
- this Object[] being compared to.public boolean equals(List)
null
, the result
is false
.
assert ["a", 2].equals(["a", 2]) assert ![2, "a"].equals("a", 2) assert [2.0, "a"].equals(2L, "a") // number comparison at work
right
- the List being compared to..true
if the contents of both lists are identical,
false
otherwise.public Process execute()
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
public Process execute(String[], File)
envp
and under the working directory dir
.
The first item in the list is the command; the others are the parameters. The toString()
method is called on items in the list to convert them to Strings.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
envp
- an array of Strings, each member of which
has environment variable settings in the format
name=value, or
null if the subprocess should inherit
the environment of the current process..dir
- the working directory of the subprocess, or
null if the subprocess should inherit
the working directory of the current process..public Process execute(List, File)
envp
and under the working directory dir
.
The first item in the list is the command; the others are the parameters. The toString()
method is called on items in the list to convert them to Strings.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
envp
- a List of Objects (converted to Strings using toString), each member of which
has environment variable settings in the format
name=value, or
null if the subprocess should inherit
the environment of the current process..dir
- the working directory of the subprocess, or
null if the subprocess should inherit
the working directory of the current process..public Object first()
def list = [3, 4, 2] assert list.first() == 3 assert list == [3, 4, 2]
public List getAt(Range)
def list = [1, "a", 4.5, true] assert list[1..2] == ["a", 4.5]
range
- a Range indicating the items to get.public List getAt(EmptyRange)
def list = [true, 1, 3.4] assert list[0..<0] == []
range
- a Range indicating the items to get.public List getAt(Collection)
def list = [true, 1, 3.4, false] assert list[1,0,2] == [1, true, 3.4]
indices
- a Collection of indices.public Object getAt(int)
def list = [2, "a", 5.3] assert list[1] == "a"
idx
- an index.public Object head()
def list = [3, 4, 2] assert list.head() == 3 assert list == [3, 4, 2]
public Object last()
def list = [3, 4, 2] assert list.last() == 2 assert list == [3, 4, 2]
public List minus(Collection)
assert [1, "a", true, true, false, 5.3] - [true, 5.3] == [1, "a", false]
removeMe
- a Collection of elements to remove.public List minus(Object)
assert ["a", 5, 5, true] - 5 == ["a", true]
operand
- an element to remove from the list.public Set permutations()
def result = [1, 2, 3].permutations() assert result == [[3, 2, 1], [3, 1, 2], [1, 3, 2], [2, 3, 1], [2, 1, 3], [1, 2, 3]] as Set
public Object pop()
def list = ["a", false, 2] assert list.pop() == 2 assert list == ["a", false]
public boolean push(Object)
def list = [3, 4, 2] list.push("x") assert list == [3, 4, 2, "x"]
value
- element to be appended to this list..public void putAt(int, Object)
def list = [2, 3] list[0] = 1 assert list == [1, 3]
idx
- an index.value
- the value to put at the given index.public void putAt(EmptyRange, Object)
def list = ["a", true] list[1..<1] = 5 assert list == ["a", 5, true]
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.public void putAt(EmptyRange, Collection)
def list = ["a", true] list[1..<1] = [4, 3, 2] assert list == ["a", 4, 3, 2, true]
range
- the (in this case empty) subset of the list to set.value
- the Collection of values.public void putAt(IntRange, Collection)
def myList = [4, 3, 5, 1, 2, 8, 10] myList[3..5] = ["a", true] assert myList == [4, 3, 5, "a", true, 10]Items in the given range are relaced with items from the collection.
range
- the subset of the list to set.col
- the collection of values to put at the given sublist.public void putAt(IntRange, Object)
def myList = [4, 3, 5, 1, 2, 8, 10] myList[3..5] = "b" assert myList == [4, 3, 5, "b", 10]Items in the given range are relaced with the operand. The
value
operand is
always treated as a single value.range
- the subset of the list to set.value
- the value to put at the given sublist.public void putAt(List, List)
def list = ["a", true, 42, 9.4] list[1, 4] = ["x", false] assert list == ["a", "x", 42, 9.4, false]
splice
- the subset of the list to set.values
- the value to put at the given sublist.public void putAt(List, Object)
def list = ["a", true, 42, 9.4] list[1, 3] = 5 assert list == ["a", 5, 42, 5]
splice
- the subset of the list to set.value
- the value to put at the given sublist.public List reverse()
def list = ["a", 4, false] assert list.reverse() == [false, 4, "a"] assert list == ["a", 4, false]
public List reverseEach(Closure)
def result = [] [1,2,3].reverseEach { result << it } assert result == [3,2,1]
closure
- a closure to which each item is passed..public Set subsequences()
def result = [1, 2, 3].subsequences() assert result == [[1, 2, 3], [1, 3], [2, 3], [1, 2], [1], [2], [3]] as Set
public List tail()
def list = [3, 4, 2] assert list.tail() == [4, 2] assert list == [3, 4, 2]
public List transpose()
def result = [['a', 'b'], [1, 2]].transpose() assert result == [['a', 1], ['b', 2]]
|
Groovy JDK |