indexed_set 1.0.0

  • Installing
  • Versions
  • 46

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

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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


We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
80 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:indexed_set/indexed_set.dart.


  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • The description is too long.

    Search engines will display only the first part of the description. Try to keep it under 180 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use indexed_set.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run dartfmt to format lib/src/indexed_set.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
built_collection ^2.1.3 2.1.3 3.1.1
collection ^1.4.0 1.14.10
quiver ^0.25.0 0.25.0 0.29.0+1
Transitive dependencies
matcher 0.12.2+1
path 1.6.0
stack_trace 1.9.2
Dev dependencies
test any