sortedmap 0.4.2
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.
SortedMap #
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
}
FilteredMap #
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)
}
Features and bugs #
Please file feature requests and bugs at the issue tracker.
Changelog #
0.4.2 #
- Support Dart 2 in
pubspec.yaml
0.4.1 #
- fixes on Dart 2 compatibility
0.4.0 #
- Dart 2 pre-release compatibility
0.3.1 #
- performance improvements
0.3.0 #
- resolve strong mode analysis warnings
- change dependency on quiver to <0.28.0
0.2.0 #
- new FilteredMapView class
- some api changes
0.1.2 #
- keep elements after limit in FilteredMap
0.1.1 #
compare
andisValid
methods iso getters inFilter
- strong mode fixes
- linter
0.1.0 #
- Initial version
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
sortedmap: ^0.4.2
2. Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter pub get
Alternatively, your editor might support pub get
or flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:sortedmap/sortedmap.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
80
|
Health:
Code health derived from static analysis.
[more]
|
59
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
58
|
Overall:
Weighted score of the above.
[more]
|
69
|
We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.13.1+4
Health suggestions
Fix lib/src/treeset.dart
. (-19.79 points)
Analysis of lib/src/treeset.dart
reported 44 hints, including:
line 11 col 12: Unnecessary new keyword.
line 19 col 21: Use =
to separate a named parameter from its default value.
line 19 col 44: Use =
to separate a named parameter from its default value.
line 30 col 25: Unnecessary new keyword.
line 45 col 15: Unnecessary new keyword.
Fix lib/src/sortedmap.dart
. (-12.22 points)
Analysis of lib/src/sortedmap.dart
reported 26 hints, including:
line 10 col 7: Unnecessary new keyword.
line 15 col 12: Unnecessary new keyword.
line 32 col 24: Use =
to separate a named parameter from its default value.
line 33 col 27: Unnecessary new keyword.
line 54 col 27: Unnecessary new keyword.
Fix lib/src/filteredmap.dart
. (-7.24 points)
Analysis of lib/src/filteredmap.dart
reported 15 hints, including:
line 12 col 7: Unnecessary new keyword.
line 12 col 36: Unnecessary new keyword.
line 23 col 7: DO use curly braces for all flow control structures.
line 27 col 14: Unnecessary new keyword.
line 30 col 14: Unnecessary new keyword.
Fix additional 5 files with analysis or formatting issues. (-9.38 points)
Additional issues in the following files:
lib/src/filter.dart
(8 hints)lib/src/treemap.dart
(7 hints)lib/src/ordering.dart
(2 hints)lib/src/pair.dart
(2 hints)lib/sortedmap.dart
(Rundartfmt
to formatlib/sortedmap.dart
.)
Maintenance suggestions
Package is getting outdated. (-32.05 points)
The package was last published 68 weeks ago.
Maintain an example. (-10 points)
Create a short demo in the example/
directory to show how to use this package.
Common filename patterns include main.dart
, example.dart
, and sortedmap.dart
. Packages with multiple examples should provide example/README.md
.
For more information see the pub package layout conventions.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.14.0 <3.0.0 | ||
quiver | >=0.22.0 <3.0.0 | 2.1.2+1 | |
Transitive dependencies | |||
matcher | 0.12.6 | ||
meta | 1.1.8 | ||
path | 1.6.4 | ||
stack_trace | 1.9.3 | ||
Dev dependencies | |||
benchmark_harness | ^1.0.4 | ||
test | >=0.12.0 <2.0.0 |