role Setty

class Setty does QuantHash { }

A role for collections of unique objects. See Set and SetHash.


method grab

method grab($count = 1)

Like pick, a grab returns a random selection of elements, deleting the elements as they are picked. Unlike pick, it works only on mutable structures. Use of grab on an immutable structure results in an exception (much like push would).

method grabpairs

method grabpairs($count = 1)

Similar to grab, but instead of returning keys, returns the grabbed values as a list of Pair objects, whose keys are the deleted keys and whose values are True.

method pick

method pick($count = 1)

Returns $count elements chosen at random and without repetition from the Setty object.

method roll

method roll($count = 1)

method keys

The keys of a Setty object are just its elements. Therefore, keys simply returns a list of the object's elements.

method values

The values of a Setty object are always True. Therefore, values simply returns a list containing as many Trues as the object has elements

method kv

Returns a list of elements and True values interleaved.

method elems

method elems(--> Int)

The number of elements.

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 new-fp

method new-fp(*@pairs --> Setty)

Creates a new Setty object from a list of pairs.

method ACCEPTS

method ACCEPTS($other)

Returns True if $other and self contain all the same elements, and no others.

Type graph

Below you should see an image showing the type relations for Setty. If not, try the PNG version.

perl6-type-graph Setty Setty QuantHash QuantHash Setty->QuantHash Associative Associative QuantHash->Associative Mu Mu Any Any Any->Mu Set Set Set->Setty Set->Any SetHash SetHash SetHash->Setty SetHash->Any