Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
[_firebase_database_collection_vm] Add unionWith to sorted set to mir…
Browse files Browse the repository at this point in the history
…ror Web SDK.
  • Loading branch information
long1eu committed Jan 24, 2021
1 parent 8580efe commit 1d6f449
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 3 additions & 1 deletion firebase_core/_firebase_database_collection_vm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.0.2+1
## 0.0.3
- add unionWith to sorted set to mirror Web SDK.

## 0.0.2+1
- constrain test, collection, meta dependency

## 0.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ class ImmutableSortedSet<T> extends Iterable<T> {
return ImmutableSortedSet<T>._(_map.insert(entry, null));
}

ImmutableSortedSet<T> unionWith(ImmutableSortedSet<T> other) {
ImmutableSortedSet<T> result = this;

// Make sure `result` always refers to the larger one of the two sets.
if (result.length < other.length) {
result = other;
other = this;
}

for (T elem in other) {
result = result.insert(elem);
}

return result;
}

T get minEntry => _map.minKey;

T get maxEntry => _map.maxKey;
Expand Down Expand Up @@ -70,10 +86,7 @@ class ImmutableSortedSet<T> extends Iterable<T> {

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ImmutableSortedSet &&
runtimeType == other.runtimeType &&
_map == other._map;
identical(this, other) || other is ImmutableSortedSet && runtimeType == other.runtimeType && _map == other._map;

@override
int get hashCode => _map.hashCode;
Expand Down
6 changes: 4 additions & 2 deletions firebase_core/_firebase_database_collection_vm/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: _firebase_database_collection_vm
description: For internal use of the Firestore and Realtime Database packages
version: 0.0.2+1
version: 0.0.3
homepage: https://github.com/fluttercommunity/firebase_flutter_sdk

environment:
Expand All @@ -9,4 +9,6 @@ environment:
dev_dependencies:
test: '>=1.0.0 <2.0.0'
dart_quickcheck:
git: https://github.com/long1eu/dart_quickcheck.git
git: https://github.com/long1eu/dart_quickcheck.git

latest_commit: a94d79a90b737dde059fc53a56ed21c22e2498ee

0 comments on commit 1d6f449

Please sign in to comment.