# role Setty

Collection of distinct objects

```
class Setty does QuantHash { }
```

A role for collections which make sure that each element can only appear once. See Set and SetHash.

# Methods

## method grab

```
method grab($count = 1)
```

Removes and returns `$count`

elements chosen at random (without repetition) from the set.

If `*`

is passed as `$count`

, or `$count`

is greater than or equal to the size of the set, then all its elements are removed and returned in random order.

Only works on mutable sets; When used on an immutable set, it results in an exception.

## method grabpairs

```
method grabpairs($count = 1)
```

Removes `$count`

elements chosen at random (without repetition) from the set, and returns a list of `Pair`

objects whose keys are the grabbed elements and whose values are `True`

.

If `*`

is passed as `$count`

, or `$count`

is greater than or equal to the size of the set, then all its elements are removed and returned as `Pair`

s in the aforementioned way in random order.

Only works on mutable sets; When used on an immutable set, it results in an exception.

## method pick

```
multi method pick($count = 1)
```

Returns `$count`

elements chosen at random (without repetition) from the set.

If `*`

is passed as `$count`

, or `$count`

is greater than or equal to the size of the set, then all its elements are returned in random order.

## method roll

```
multi method roll($count = 1)
```

Returns a lazy list of `$count`

elements, each randomly selected from the set. Each random choice is made independently, like a separate die roll where each die face is a set element.

If `*`

is passed as `$count`

, the list is infinite.

## method keys

Returns a list of all elements of the set.

## method values

Returns a list containing as many `True`

values as the set has elements.

## method kv

Returns a list of the set's elements and `True`

values interleaved.

## method elems

```
method elems(--> Int)
```

The number of elements of the set.

## method total

```
method total(--> Int)
```

The total of all the values of the `QuantHash`

object. For a `Setty`

object, this is just the number of elements.

## method ACCEPTS

```
method ACCEPTS($other)
```

Returns `True`

if `$other`

and `self`

contain all the same elements, and no others.

# See Also

# Type graph

Below you should see a clickable image showing the type relations for Setty that links to the documentation pages for the related types. If not, try the PNG version instead.