java.util
Class Set
Method Summary |
Set
|
asImmutable()
A convenience method for creating an immutable list.
|
Set
|
asSynchronized()
A convenience method for creating a synchronized Set.
|
boolean
|
equals(Set other)
Compare the contents of two Sets for equality using Groovy's coercion rules.
|
Set
|
minus(Collection operands)
Create a Set composed of the elements of the first set minus the
elements of the given collection.
|
Set
|
minus(Object operand)
Create a Set composed of the elements of the first set minus the operand.
|
asImmutable
public Set asImmutable()
-
- A convenience method for creating an immutable list.
- Returns:
- an immutable Set
- Since:
- 1.0
- See:
- Collections#unmodifiableSet.
asSynchronized
public Set asSynchronized()
-
- A convenience method for creating a synchronized Set.
- Returns:
- a synchronized Set
- Since:
- 1.0
- See:
- Collections#synchronizedSet.
equals
public boolean equals(Set other)
-
- Compare 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)
- Parameters:
other
- the Set being compared to.
- Returns:
- true if the contents of both sets are identical
- Since:
- 1.8.0
minus
public Set minus(Collection operands)
-
- Create a Set composed of the elements of the first set minus the
elements of the given collection.
- Parameters:
operands
- the items to remove from the set.
- Returns:
- the resulting set
- Since:
- 1.5.0
minus
public Set minus(Object operand)
-
- Create a Set composed of the elements of the first set minus the operand.
- Parameters:
operand
- the operand to remove from the set.
- Returns:
- the resulting set
- Since:
- 1.5.0