https://github.com/adventuresmith/dart_collection_sampler
a small library implementing methods to sample items from collections
https://github.com/adventuresmith/dart_collection_sampler
Last synced: 5 months ago
JSON representation
a small library implementing methods to sample items from collections
- Host: GitHub
- URL: https://github.com/adventuresmith/dart_collection_sampler
- Owner: Adventuresmith
- License: mit
- Created: 2017-12-01T09:21:56.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2022-12-08T05:10:42.000Z (over 3 years ago)
- Last Synced: 2023-08-20T21:43:33.409Z (almost 3 years ago)
- Language: Dart
- Size: 53.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# dart_collection_sampler
[](https://pub.dartlang.org/packages/dart_collection_sampler)
[](https://github.com/Adventuresmith/dart_collection_sampler/actions/workflows/dart.yml)
[](https://codecov.io/gh/Adventuresmith/dart_collection_sampler)
[](CODE_OF_CONDUCT.md)
a small library implementing methods to sample items from collections
## Usage
A simple usage example:
```dart
void deal(int n, List items, {required bool unique}) {
stdout.writeln("Picking $n from $items (unique: $unique)\n");
if (n == 1) {
stdout.writeln("Selected item: ${CollectionSampler().pick(items)}");
} else {
stdout.writeln(
"Selected items: ${CollectionSampler().pickN(items, n, unique: unique)}",
);
}
}
```
## Features and bugs
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/Adventuresmith/dart_collection_sampler/issues