Return type | Name and parameters |
---|---|
Set
|
and(Iterable right)
Creates a Set composed of the intersection of a Set and an Iterable. |
Set
|
and(Iterable right, Comparator comparator)
Creates a Set composed of the intersection of a Set and an Iterable. |
Set
|
asChecked(Class type)
Creates a checked view of a Set. |
Set
|
asImmutable()
A convenience method for creating an immutable Set. |
Set
|
asSynchronized()
Creates a synchronized view of a Set. |
Set
|
asUnmodifiable()
Creates an unmodifiable view of a Set. |
Set
|
each(Closure closure)
Iterates through a Set, passing each item to the given closure. |
Set
|
eachWithIndex(Closure closure)
Iterates through a Set, passing each item and the item's index (a counter starting at zero) to the given closure. |
boolean
|
equals(Set other)
Compare the contents of two Sets for equality using Groovy's coercion rules. |
Set
|
findAll()
Finds the items matching the IDENTITY Closure (i.e. matching Groovy truth). |
Set
|
findAll(Closure closure)
Finds all values matching the closure condition. |
Set
|
flatten()
Flatten a Set. |
Set
|
grep()
Iterates over the collection returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth. |
Set
|
grep(Object filter)
Iterates over the collection of items and returns each item that matches the given filter - calling the Object#isCase(java.lang.Object)
method used by switch statements.
|
Set
|
intersect(Iterable right)
Create a Set composed of the intersection of a Set and an Iterable. |
Set
|
intersect(Iterable right, Comparator comparator)
Create a Set composed of the intersection of a Set and an Iterable. |
Set
|
leftShift(Object value)
Overloads the left shift operator to provide an easy way to append objects to a Set. |
Set
|
minus(Iterable removeMe)
Create a Set composed of the elements of the first Set minus the elements from the given Iterable. |
Set
|
minus(Object removeMe)
Create a Set composed of the elements of the first Set minus the given element. |
Set
|
minus(Collection removeMe)
Create a Set composed of the elements of the first Set minus the elements of the given Collection. |
Set
|
or(Iterable right)
Create a Set as a union of a Set and an Iterable. |
Set
|
plus(Iterable right)
Create a Set as a union of a Set and an Iterable. |
Set
|
plus(Object right)
Create a Set as a union of a Set and an Object. |
Set
|
plus(Collection right)
Create a Set as a union of a Set and a Collection. |
List
|
split(Closure closure)
Splits all items into two collections based on the closure condition. |
Set
|
union(Iterable right)
Create a Set composed of the union of a Set and an Iterable. |
Set
|
union(Iterable right, Comparator comparator)
Create a Set composed of the union of a Set and an Iterable. |
Set
|
xor(Iterable right)
Create a Set composed of the symmetric difference of a Set and an Iterable. |
Set
|
xor(Iterable right, Comparator comparator)
Create a Set composed of the symmetric difference of a Set and an Iterable. |
addAll
, addAll
, addAll
, asBoolean
, asChecked
, asImmutable
, asSynchronized
, asType
, asUnmodifiable
, collectNested
, each
, eachWithIndex
, find
, find
, findAll
, findAll
, flatten
, getAt
, getIndices
, grep
, grep
, intersect
, intersect
, isCase
, isNotCase
, leftShift
, minus
, plus
, plus
, plus
, removeAll
, removeAll
, removeElement
, retainAll
, retainAll
, split
, toListString
, toListString
, toSet
, union
, union
, unique
, unique
, unique
, unique
, unique
, unique
any
, asCollection
, asList
, asType
, average
, average
, bufferedIterator
, chop
, collate
, collate
, collate
, collate
, collect
, collect
, collect
, collectEntries
, collectEntries
, collectEntries
, collectEntries
, collectEntries
, collectEntries
, collectMany
, collectMany
, collectNested
, collectNested
, combinations
, combinations
, contains
, containsAll
, count
, count
, count
, countBy
, countBy
, disjoint
, drop
, dropRight
, dropWhile
, each
, eachCombination
, eachPermutation
, eachWithIndex
, every
, findIndexOf
, findIndexOf
, findIndexValues
, findIndexValues
, findLastIndexOf
, findLastIndexOf
, findResult
, findResult
, findResult
, findResult
, findResults
, findResults
, first
, flatten
, flatten
, flatten
, flatten
, flattenMany
, getAt
, groupBy
, groupBy
, groupBy
, head
, indexed
, indexed
, init
, inits
, inject
, inject
, intersect
, intersect
, intersect
, isCase
, isEmpty
, join
, join
, last
, max
, max
, max
, min
, min
, min
, minus
, minus
, minus
, minus
, multiply
, permutations
, permutations
, plus
, plus
, size
, sort
, sort
, sort
, sort
, sort
, stream
, sum
, sum
, sum
, sum
, tail
, tails
, take
, takeRight
, takeWhile
, toList
, toSet
, toSorted
, toSorted
, toSorted
, toSpreadMap
, toUnique
, toUnique
, toUnique
, union
, union
, union
, withCollectedKeys
, withCollectedKeys
, withCollectedValues
, withCollectedValues
, withIndex
, withIndex
, zip
Creates a Set composed of the intersection of a Set and an Iterable. Any elements that exist in both are added to the resultant Set.
This operation will always create a new object for the result, while the operands remain unchanged.
def a = [1,2,3,4] as Set def b = [3,4,5,6] as Set assert (a & b) == [3,4] as SetBy default, Groovy uses a NumberAwareComparator when determining if an element exists in both sets.
right
- an IterableCreates a Set composed of the intersection of a Set and an Iterable. Any elements that exist in both iterables are added to the resultant collection.
This operation will always create a new object for the result, while the operands remain unchanged.
assert [3,4] as Set == ([1,2,3,4] as Set).and([3,4,5,6], Comparator.naturalOrder())
right
- an Iterablecomparator
- a ComparatorCreates a checked view of a Set.
A convenience method for creating an immutable Set.
Creates a synchronized view of a Set.
Creates an unmodifiable view of a Set.
Iterates through a Set, passing each item to the given closure.
closure
- the closure applied on each element foundIterates through a Set, passing each item and the item's index (a counter starting at zero) to the given closure.
closure
- a Closure to operate on each itemCompare the contents of two Sets for equality using Groovy's coercion rules.
Returns true if the two sets have the same size, and every member
of the specified set is contained in this set (or equivalently, every member
of this set is contained in the specified set).
If numbers exist in the sets, then they are compared as numbers,
for example 2 == 2L. If both sets are null
, the result
is true; otherwise if either set is null
, the result
is false
. Example usage:
Set s1 = ["a", 2] def s2 = [2, 'a'] as Set Set s3 = [3, 'a'] def s4 = [2.0, 'a'] as Set def s5 = [2L, 'a'] as Set assert s1.equals(s2) assert !s1.equals(s3) assert s1.equals(s4) assert s1.equals(s5)
other
- the Set being compared toFinds the items matching the IDENTITY Closure (i.e. matching Groovy truth).
Example:
def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null] as Set assert items.findAll() == [1, 2, true, 'foo', [4, 5]] as Set
Finds all values matching the closure condition.
assert ([2,4] as Set) == ([1,2,3,4] as Set).findAll { it % 2 == 0 }
closure
- a closure conditionFlatten a Set. This Set and any nested arrays or collections have their contents (recursively) added to the new Set.
assert [1,2,3,4,5] as Set == ([1,[2,3],[[4]],[],5] as Set).flatten()
Iterates over the collection returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
Example:
def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null] as Set assert items.grep() == [1, 2, true, 'foo', [4, 5]] as Set
Iterates over the collection of items and returns each item that matches
the given filter - calling the Object#isCase(java.lang.Object)
method used by switch statements. This method can be used with different
kinds of filters like regular expressions, classes, ranges etc.
Example:
def set = ['a', 'b', 'aa', 'bc', 3, 4.5] as Set assert set.grep( ~/a+/ ) == ['a', 'aa'] as Set assert set.grep( ~/../ ) == ['aa', 'bc'] as Set assert set.grep( Number ) == [ 3, 4.5 ] as Set assert set.grep{ it.toString().size() == 1 } == [ 'a', 'b', 3 ] as Set
filter
- the filter to perform on each element of the collection (using the Object#isCase(java.lang.Object) method)Create a Set composed of the intersection of a Set and an Iterable. Any elements that exist in both iterables are added to the resultant collection.
assert [4,5] as Set == ([1,2,3,4,5] as Set).intersect([4,5,6,7,8])By default, Groovy uses a NumberAwareComparator when determining if an element exists in both collections.
right
- an IterableCreate a Set composed of the intersection of a Set and an Iterable. Any elements that exist in both iterables are added to the resultant collection.
assert [3,4] as Set == ([1,2,3,4] as Set).intersect([3,4,5,6], Comparator.naturalOrder())
right
- an Iterablecomparator
- a ComparatorOverloads the left shift operator to provide an easy way to append objects to a Set.
def set = [1,2] as Set set << 3 assert set == [1,2,3] as Set
value
- an Object to be added to the Set.Create a Set composed of the elements of the first Set minus the elements from the given Iterable.
removeMe
- the items to remove from the SetCreate a Set composed of the elements of the first Set minus the given element.
removeMe
- the element to remove from the SetCreate a Set composed of the elements of the first Set minus the elements of the given Collection.
removeMe
- the items to remove from the SetCreate a Set as a union of a Set and an Iterable. Any elements that exist in either are added to the resultant Set.
This operation will always create a new object for the result, while the operands remain unchanged.
def a = [1,2,3,4] as Set def b = [3,4,5,6] as Set assert (a | b) == [1,2,3,4,5,6] as Set
right
- the right IterableCreate a Set as a union of a Set and an Iterable. This operation will always create a new object for the result, while the operands remain unchanged.
right
- the right IterableCreate a Set as a union of a Set and an Object. This operation will always create a new object for the result, while the operands remain unchanged.
assert [1,2,3] == [1,2] + 3
right
- an object to add/appendCreate a Set as a union of a Set and a Collection. This operation will always create a new object for the result, while the operands remain unchanged.
right
- the right CollectionSplits all items into two collections based on the closure condition. The first list contains all items which match the closure expression. The second list all those that don't.
Example usage:
assert [[2,4] as Set, [1,3] as Set] == ([1,2,3,4] as Set).split { it % 2 == 0 }
closure
- a closure conditionCreate a Set composed of the union of a Set and an Iterable. Any elements that exist in either iterables are added to the resultant collection, such that no elements are duplicated in the resultant collection.
assert [1,2,3,4,5,6,7,8] as Set == ([1,2,3,4,5] as Set).union([4,5,6,7,8])By default, Groovy uses a NumberAwareComparator when determining if an element already exists in the resultant collection.
right
- an IterableCreate a Set composed of the union of a Set and an Iterable. Any elements that exist in either iterables are added to the resultant collection, such that no elements are duplicated in the resultant collection.
assert [1,2,3,4,5,6] as Set == ([1,2,3,4] as Set).union([3,4,5,6], Comparator.naturalOrder())
right
- an Iterablecomparator
- a ComparatorCreate a Set composed of the symmetric difference of a Set and an Iterable. Any elements that exit in only one are added to the resultant Set.
This operation will always create a new object for the result, while the operands remain unchanged.
def a = [1,2,3,4] as Set def b = [3,4,5,6] as Set assert (a ^ b) == [1,2,5,6] as SetBy default, Groovy uses a NumberAwareComparator when determining if an element exists in both sets.
right
- an IterableCreate a Set composed of the symmetric difference of a Set and an Iterable. Any elements that exit in only one are added to the resultant Set.
This operation will always create a new object for the result, while the operands remain unchanged.
assert [1,2,5,6] as Set == ([1,2,3,4] as Set).xor([3,4,5,6], Comparator.naturalOrder())
right
- an Iterablecomparator
- a Comparator