indexed_set 1.0.0+2 copy "indexed_set: ^1.0.0+2" to clipboard
indexed_set: ^1.0.0+2 copied to clipboard

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
40
pub points
0%
popularity

Publisher

unverified uploader

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

License

MIT (LICENSE)

Dependencies

built_collection, collection, meta, quiver

More

Packages that depend on indexed_set