indexed_set 1.0.0+2

IndexedSet is a Set implementation that computes an index for each of its elements and exposes this mapping through the [] operator.

example/indexed_set.dart

import 'package:indexed_set/indexed_set.dart';

enum System { frontend, backend }

class Account {
  final String name;
  final System system;

  Account(this.name, this.system);

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

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

void main() {
  frontendAccounts
    ..add(Account('Alice', System.frontend))
    ..add(Account('Bob', System.frontend));

  // Supports element access through the user-specified index
  print(frontendAccounts['Alice']);
}
0
likes
80
pub points
0%
popularity

IndexedSet is a Set implementation that computes an index for each of its elements and exposes this mapping through the [] operator.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

philippschiffmann93@gmail.com

License

MIT (LICENSE)

Dependencies

built_collection, collection, meta, quiver

More

Packages that depend on indexed_set