comparator_sorted_map 1.0.1 copy "comparator_sorted_map: ^1.0.1" to clipboard
comparator_sorted_map: ^1.0.1 copied to clipboard

outdated

A SortedMap that relies on a Comparator to sort on key, value, or a combination of both.

A SortedMap in Dart.

Requires a Comparator on construction that allows sorting by key, value, or a combination of both.

Also includes the ability to limit the map's capacity. If the map's capacity is limited it will eject over capacity entries from either the beginning or end of the sort when new entries are added.

Usage #

A simple usage example:

import 'package:comparator_sorted_map/comparator_sorted_map.dart';

main() {
  //Sort by value
  SortedMap sortByValue = SortedMap(comparator: (a, b) => a.value.compareTo(b.value));
  sortByValue[0] = 'Z';
  sortByValue[1] = 'Y';
  sortByValue[2] = 'X';

  Iterable keys = sortByValue.keys;
  print(keys);
  //Should print [2, 1, 0]

  Iterable values = sortByValue.values;
  print(values);
  //Should print ['X', 'Y', 'Z']
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1
likes
0
pub points
17%
popularity

Publisher

verified publishersoftcoil.com

A SortedMap that relies on a Comparator to sort on key, value, or a combination of both.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

logging

More

Packages that depend on comparator_sorted_map