Contains a SortedMap
and FilteredMap
class, which hold a map of objects that can be ordered relative to each other.
Unlike SplayTreeMap
the objects can be ordered on both key and value or a combination of both.
The FilteredMap
also allows to specify an isValid
function on key/value pairs and limit the number of objects
allowed in the map.
A simple usage example:
import 'package:sortedmap/sortedmap.dart';
main() {
var map = new SortedMap((Pair a, Pair b)=>Comparable.compare(a.value, b.value));
map.addAll({
"a": 3,
"b": 2,
"c": 4,
"d": 1
});
print(map.lastKeyBefore("c")); // a
print(map.firstKeyAfter("d")); // b
}
A simple usage example:
import 'package:sortedmap/sortedmap.dart';
main() {
var map = new FilteredMap(new Filter(
compare: (Pair a, Pair b)=>Comparable.compare(a.value, b.value),
isValid: (Pair v) => v.key!="b",
limit: 2));
map.addAll({
"a": 3,
"b": 2,
"c": 4,
"d": 1
});
print(map.keys); // (d, a)
}
Please file feature requests and bugs at the issue tracker.
compare
and isValid
methods iso getters in Filter
Add this to your package's pubspec.yaml file:
dependencies:
sortedmap: "^0.3.0"
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.
Now in your Dart code, you can use:
import 'package:sortedmap/sortedmap.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.3.0 | Mar 19, 2018 |
|
|
0.2.0 | Mar 7, 2017 |
|
|
0.1.2 | Feb 10, 2017 |
|
|
0.1.1 | Jun 17, 2016 |
|
|
0.1.0 | Jun 7, 2016 |
|
|
We analyzed this package on Apr 9, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
32 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
100 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
66 |
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:sortedmap/sortedmap.dart
.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*
, it usually means that the author is still experimenting with the general direction API.
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 usesortedmap.dart
.