CollectionSampler class

Samples collections

selecting N items from collections is done via Resevoir Sampling, see reservoirSampling for more details.

Constructors

CollectionSampler([Random? r])
Construct new collection sampler w/ injectible random

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pick<T>(List<T> items) → T
pick an item at random from the list -- restricted to List because size is known, and elementAt is implemented efficiently.
pickFromMap<K, V>(Map<K, V> itemMap) → V
pick an value at random from the map
pickN<T>(Iterable<T> items, int N, {bool unique = true}) List<T>
Picks N items from iterable, optionally make it unique.
pickUniqueNFromMap<K, V>(Map<K, V> itemMap, int n) Iterable<V>
picks N items from Map (returning map values)
pickUniqueNFromMapAsMap<K, V>(Map<K, V> itemMap, int n) Map<K, V>
pick N unique values from the map. will return at most itemMap.length items
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited