dart_collection_sampler 0.5.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 0

dart_collection_sampler

a small library implementing methods to sample items from collections

Usage

A simple usage example:

import 'package:args/args.dart';

import 'dart:io';
import 'package:dart_collection_sampler/dart_collection_sampler.dart';

main(List<String> arguments) {

  var argParser = new ArgParser()
      ..addOption("num", abbr: "n", help: "items to pick from rest of command line", defaultsTo: "1");
  
  var results = argParser.parse(arguments);

  exit(
    roll(int.parse(results["num"]), results.rest)
  );
}

int roll(int n, List<String> items) {
  if (items.isEmpty) {
    print ("you must supply one or more items as input");
    return 1;
  }
  print ("Picking $n from $items\n");

  if (n == 1) {
    print ("Selected item: ${new CollectionSampler().pick(items)}");
  } else {
    print ("Selected items: ${new CollectionSampler().pickN(items, n)}");
  }
  return 0;
}



Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.5.1

  • fix problem introduced by 0.5.0 changes for fixed-length reservoir

0.5.0

  • initialize reservoir size
  • clarify some details of reservoir sampling algorithm in method doc

0.4.0

  • clarify which selection methods return unique and non-unique

0.3.0

  • fix dumb comment in example

0.2.0

  • clean up all samplers to use reservoir sampling
  • add example code

0.1.0

  • fix up interfaces to use List, implement ReservoirSampler

0.0.1

  • Initial version, created by Steve Christensen

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_collection_sampler: ^0.5.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_collection_sampler/dart_collection_sampler.dart';
  
Version Uploaded Documentation Archive
0.5.1 Dec 10, 2017 Go to the documentation of dart_collection_sampler 0.5.1 Download dart_collection_sampler 0.5.1 archive
0.5.0 Dec 9, 2017 Go to the documentation of dart_collection_sampler 0.5.0 Download dart_collection_sampler 0.5.0 archive
0.4.0 Dec 8, 2017 Go to the documentation of dart_collection_sampler 0.4.0 Download dart_collection_sampler 0.4.0 archive
0.3.0 Dec 2, 2017 Go to the documentation of dart_collection_sampler 0.3.0 Download dart_collection_sampler 0.3.0 archive
0.2.0 Dec 2, 2017 Go to the documentation of dart_collection_sampler 0.2.0 Download dart_collection_sampler 0.2.0 archive
0.1.0 Dec 2, 2017 Go to the documentation of dart_collection_sampler 0.1.0 Download dart_collection_sampler 0.1.0 archive
0.0.2 Dec 2, 2017 Go to the documentation of dart_collection_sampler 0.0.2 Download dart_collection_sampler 0.0.2 archive
0.0.1 Dec 1, 2017 Go to the documentation of dart_collection_sampler 0.0.1 Download dart_collection_sampler 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0