Documentation Set for Swarm 2.2
Prev | Reference II. Collections Library | Next

# ListShuffler

## Name

ListShuffler -- A class to randomize the order of a given Swarm List

## Description

ListShuffler randomizes the order of the elements in a List; either the whole list or the num lowest elements. The list must be supplied. An uniform distribution can be supplied, or the system- supplied uniformUnsRand is used. The algorithm is from Knuth. All these methods modify the underlying collection, so any indexes should always be regenerated.

## Protocols adopted by ListShuffler

Create Drop CREATABLE

## Methods

### Phase: Creating

- + create: (id <Zone>)aZone setUniformRandom: dist
  The create:setUniformRandom method creates the Shuffler and connects the supplied distribution object.

- - setUniformRandom: dist
  the setUniformRandom: method connects the supplied uniform distribution to the Shuffler (run after createBegin:).

### Phase: Using

- - shufflePartialList: list Num: (unsigned)num
  the shufflePartialList:Num method randomizes the order of the 'num' lowest elements of the list, or the whole list if (num > size of list).

- - shuffleWholeList: list
  the shuffleWholeList method randomizes the whole list.

Prev | Home | Next
ListIndex | Up | Map