indexed_set 1.0.0

  • Installing
  • Versions
  • 0

Dart indexed set

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


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.system);

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

/// Supports lookup of accounts by username.
final frontendAccounts = new IndexedSet<String, Account>(
    (Account acc) =>,
    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:

  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
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
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


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