Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Unified Diff: runtime/lib/collection_patch.dart

Issue 26280002: Set.add returns true if item has been added, otherwise false (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: again Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/lib/collection_patch.dart
diff --git a/runtime/lib/collection_patch.dart b/runtime/lib/collection_patch.dart
index ea953063fe5c055d8f0b28e1be21391f4a4dca02..d2331c37030574eeb62da48fe3f2f32c72ac2d14 100644
--- a/runtime/lib/collection_patch.dart
+++ b/runtime/lib/collection_patch.dart
@@ -583,15 +583,16 @@ class _HashSet<E> extends _HashSetBase<E> implements HashSet<E> {
// Set.
- void add(E element) {
+ bool add(E element) {
int hashCode = _hashCode(element);
int index = hashCode & (_buckets.length - 1);
HashSetEntry entry = _buckets[index];
while (entry != null) {
- if (_equals(entry.key, element)) return;
+ if (_equals(entry.key, element)) return false;
entry = entry.next;
}
_addEntry(element, hashCode, index);
+ return true;
}
void addAll(Iterable<E> objects) {
« no previous file with comments | « pkg/unmodifiable_collection/lib/unmodifiable_collection.dart ('k') | sdk/lib/_internal/lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698