sortedmap 0.4.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 81

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 and isValid methods iso getters in Filter
  • 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 packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
0.4.2 Aug 14, 2018 Go to the documentation of sortedmap 0.4.2 Download sortedmap 0.4.2 archive
0.4.1 Jul 18, 2018 Go to the documentation of sortedmap 0.4.1 Download sortedmap 0.4.1 archive
0.4.0 Jul 12, 2018 Go to the documentation of sortedmap 0.4.0 Download sortedmap 0.4.0 archive
0.3.1 Jul 12, 2018 Go to the documentation of sortedmap 0.3.1 Download sortedmap 0.3.1 archive
0.3.0 Mar 19, 2018 Go to the documentation of sortedmap 0.3.0 Download sortedmap 0.3.0 archive
0.2.0 Mar 7, 2017 Go to the documentation of sortedmap 0.2.0 Download sortedmap 0.2.0 archive
0.1.2 Feb 10, 2017 Go to the documentation of sortedmap 0.1.2 Download sortedmap 0.1.2 archive
0.1.1 Jun 17, 2016 Go to the documentation of sortedmap 0.1.1 Download sortedmap 0.1.1 archive
0.1.0 Jun 7, 2016 Go to the documentation of sortedmap 0.1.0 Download sortedmap 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:sortedmap/sortedmap.dart.

Health suggestions

Format lib/sortedmap.dart.

Run dartfmt to format lib/sortedmap.dart.

Format lib/src/filter.dart.

Run dartfmt to format lib/src/filter.dart.

Format lib/src/filteredmap.dart.

Run dartfmt to format lib/src/filteredmap.dart.

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/ordering.dart (Run dartfmt to format lib/src/ordering.dart.)
  • lib/src/sortedmap.dart (Run dartfmt to format lib/src/sortedmap.dart.)
  • lib/src/treemap.dart (Run dartfmt to format lib/src/treemap.dart.)
  • lib/src/treeset.dart (Run dartfmt to format lib/src/treeset.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

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 use sortedmap.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.14.0 <3.0.0
quiver >=0.22.0 <3.0.0 2.0.0+1
Transitive dependencies
matcher 0.12.4
meta 1.1.6
path 1.6.2
stack_trace 1.9.3
Dev dependencies
benchmark_harness ^1.0.4
test >=0.12.0 <2.0.0