-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new Dart 2 Map, Iterable, and List methods to multimap stuff #425
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b02417
Add implementations of some Dart 2 methods in multimap.dart
srawlins 281670a
Fix
srawlins eea3b65
Type List for DDC?
srawlins c5cac82
Feedback
srawlins d0056af
Merge branch 'master' into core-libs-dart-3
srawlins 685a2a8
Merge branch 'master' into core-libs-dart-3
cbracken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,51 +309,44 @@ class _WrappedMap<K, V, C extends Iterable<V>> implements Map<K, C> { | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_getter | ||
Iterable<Null> get entries { | ||
// Change Iterable<Null> to Iterable<MapEntry<K, V>> when | ||
// the MapEntry class has been added. | ||
throw new UnimplementedError("entries"); | ||
Iterable<MapEntry<K, C>> get entries { | ||
return keys.map((K key) => new MapEntry<K, C>(key, this[key])); | ||
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
void addEntries(Iterable<Object> entries) { | ||
// Change Iterable<Object> to Iterable<MapEntry<K, V>> when | ||
// the MapEntry class has been added. | ||
throw new UnimplementedError("addEntries"); | ||
void addEntries(Iterable<MapEntry<K, C>> entries) { | ||
throw new UnsupportedError("Insert unsupported on map view"); | ||
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
Map<K2, V2> map<K2, V2>(Object transform(K key, C value)) { | ||
// Change Object to MapEntry<K2, V2> when | ||
// the MapEntry class has been added. | ||
throw new UnimplementedError("map"); | ||
Map<K2, C2> map<K2, C2>(MapEntry<K2, C2> transform(K key, C value)) { | ||
var result = <K2, C2>{}; | ||
for (var key in this.keys) { | ||
var entry = transform(key, this[key]); | ||
result[entry.key] = entry.value; | ||
} | ||
return result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Map<K2, C2> map<K2, C2>(MapEntry<K2, C2> transform(K key, C value)) =>
_multimap._map.map(transform); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
C update(K key, C update(C value), {C ifAbsent()}) { | ||
throw new UnimplementedError("update"); | ||
throw new UnsupportedError("Update unsupported on map view"); | ||
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
void updateAll(C update(K key, C value)) { | ||
throw new UnimplementedError("updateAll"); | ||
throw new UnsupportedError("Update unsupported on map view"); | ||
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
void removeWhere(bool test(K key, C value)) { | ||
throw new UnimplementedError("removeWhere"); | ||
var keysToRemove = <K>[]; | ||
for (var key in keys) { | ||
if (test(key, this[key])) keysToRemove.add(key); | ||
} | ||
for (var key in keysToRemove) { | ||
_multimap.removeAll(key); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -430,10 +423,9 @@ class _WrappedIterable<K, V, C extends Iterable<V>> implements Iterable<V> { | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
Iterable<V> followedBy(Iterable<V> other) { | ||
throw new UnimplementedError("followedBy"); | ||
_syncDelegate(); | ||
return _delegate.followedBy(other); | ||
} | ||
|
||
void forEach(void f(V element)) { | ||
|
@@ -499,9 +491,8 @@ class _WrappedIterable<K, V, C extends Iterable<V>> implements Iterable<V> { | |
} | ||
|
||
V singleWhere(bool test(V element), {V orElse()}) { | ||
if (orElse != null) throw new UnimplementedError("singleWhere:orElse"); | ||
_syncDelegate(); | ||
return _delegate.singleWhere(test); | ||
return _delegate.singleWhere(test, orElse: orElse); | ||
} | ||
|
||
Iterable<V> skip(int n) { | ||
|
@@ -565,10 +556,9 @@ class _WrappedList<K, V> extends _WrappedIterable<K, V, List<V>> | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
List<V> operator +(List<V> other) { | ||
throw new UnimplementedError("+"); | ||
_syncDelegate(); | ||
return _delegate + other; | ||
} | ||
|
||
void add(V value) { | ||
|
@@ -609,8 +599,6 @@ class _WrappedList<K, V> extends _WrappedIterable<K, V, List<V>> | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_setter | ||
void set first(V value) { | ||
if (this.isEmpty) throw new RangeError.index(0, this); | ||
this[0] = value; | ||
|
@@ -627,10 +615,9 @@ class _WrappedList<K, V> extends _WrappedIterable<K, V, List<V>> | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
int indexWhere(bool test(V element), [int start = 0]) { | ||
throw new UnimplementedError("indexWhere"); | ||
_syncDelegate(); | ||
return _delegate.indexWhere(test, start); | ||
} | ||
|
||
void insert(int index, V element) { | ||
|
@@ -648,8 +635,6 @@ class _WrappedList<K, V> extends _WrappedIterable<K, V, List<V>> | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_setter | ||
void set last(V value) { | ||
if (this.isEmpty) throw new RangeError.index(0, this); | ||
this[this.length - 1] = value; | ||
|
@@ -661,10 +646,8 @@ class _WrappedList<K, V> extends _WrappedIterable<K, V, List<V>> | |
} | ||
|
||
@override | ||
// TODO: Dart 2.0 requires this method to be implemented. | ||
// ignore: override_on_non_overriding_method | ||
int lastIndexWhere(bool test(V element), [int start]) { | ||
throw new UnimplementedError("lastIndexWhere"); | ||
return _delegate.lastIndexWhere(test, start); | ||
} | ||
|
||
void set length(int newLength) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.