Skip to content

Commit

Permalink
Merge NS branch
Browse files Browse the repository at this point in the history
  • Loading branch information
luanpotter committed Mar 13, 2021
2 parents ee8c1ef + 71d095a commit d65b0b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 3.0.0-nullsafety.0

- Add null safety for this package

## 2.0.2

- Improve repository organization
Expand Down
8 changes: 4 additions & 4 deletions lib/ordered_set.dart
Expand Up @@ -6,8 +6,8 @@ import 'dart:collection';
/// Unlike [SplayTreeSet], it allows for several different elements with the same priority to be added.
/// It also implements [Iterable], so you can iterate it in O(n).
class OrderedSet<E> extends IterableMixin<E> implements Iterable<E> {
SplayTreeSet<List<E>> _backingSet;
int _length;
late SplayTreeSet<List<E>> _backingSet;
late int _length;

// gotten from SplayTreeSet, but those are private there
static int _dynamicCompare(dynamic a, dynamic b) => Comparable.compare(
Expand All @@ -25,7 +25,7 @@ class OrderedSet<E> extends IterableMixin<E> implements Iterable<E> {
/// Creates a new [OrderedSet] with the given compare function.
///
/// If the [compare] function is omitted, it defaults to [Comparable.compare], and the elements must be comparable.
OrderedSet([int Function(E e1, E e2) compare]) {
OrderedSet([int Function(E e1, E e2)? compare]) {
final comparator = compare ?? _defaultCompare<E>();
_backingSet = SplayTreeSet<List<E>>((List<E> l1, List<E> l2) {
if (l1.isEmpty) {
Expand Down Expand Up @@ -68,7 +68,7 @@ class OrderedSet<E> extends IterableMixin<E> implements Iterable<E> {
_length++;
final added = _backingSet.add([e]);
if (!added) {
_backingSet.lookup([e]).add(e);
_backingSet.lookup([e])!.add(e);
}
return true;
}
Expand Down
7 changes: 3 additions & 4 deletions pubspec.yaml
@@ -1,14 +1,13 @@
name: ordered_set
description: A simple implementation of an Ordered Set for Dart that allows multiple items with the same priority.
version: 2.0.2
version: 3.0.0-nullsafety.0
homepage: https://github.com/luanpotter/ordered_set

environment:
sdk: '>=2.7.0 <3.0.0'
sdk: '>=2.12.0-29.10.beta <3.0.0'

dev_dependencies:
test: ^1.15.7
test: ^1.16.0-nullsafety
dart_code_metrics: ^2.4.0
dartdoc: ^0.39.0
coverage: ^0.14.2

0 comments on commit d65b0b3

Please sign in to comment.