indexed_set 1.0.0

  • README.md
  • Installing
  • Versions
  • new61

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.

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

with Flutter:


$ flutter packages get

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

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
31 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80 / 100
Overall score:
Weighted score of the above. [more]
61

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Maintain CHANGELOG.md.

    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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
built_collection ^2.1.3 2.1.3 3.0.4
collection ^1.4.0 1.14.5
quiver ^0.25.0 0.25.0 0.28.0
Transitive dependencies
matcher 0.12.1+4
path 1.5.1
stack_trace 1.9.1
Dev dependencies
test any