indexed_set 1.0.0

  • README.md
  • Installing
  • Versions
  • 0

Dart indexed set

This package provides an IndexedSet class, and a pair of Superset/Subset classes that implement the IndexedSet interface.

IndexedSet

An IndexedSet adds a mapping mechanism to the Set interface. A user-provided function I index(E element) calculates an index for each element. The elements are then accessible through the [] operator. This allows you to define cleaner APIs than if you used a Map, because the data structure can enforce integrity of the key/value mapping.

enum System { frontend, backend }

class Account {
  final String name;
  final System system;

  Account(this.name, this.system);

  String toString() => '$system-account of $name';
}

/// Supports lookup of accounts by username.
final frontendAccounts = new IndexedSet<String, Account>(
    (Account acc) => acc.name,
    isValidElement: (Account acc) => acc.system == System.frontend);

Superset / Subset

Both Superset and Subset are indexed sets that use int as the index type. A Superset is immutable and stores its elements in ascending order -- the first element will have index 0, the last element index set.length - 1. A Subset has to be taken from a superset, and can only contain elements that are also contained in the superset. This allows the subset to store its elements in a bit vector, which is both very space-efficient, and time-efficient for set operations (difference, intersection, union) on subsets of the same superset.

Use this package as a library

1. Depend on it

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


dependencies:
  indexed_set: ^1.0.0

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:indexed_set/indexed_set.dart';
  
Version Uploaded Documentation Archive
1.0.0 Jan 24, 2018 Go to the documentation of indexed_set 1.0.0 Download indexed_set 1.0.0 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.

Analysis 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.24.0 <2.0.0