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

Side by Side Diff: sdk/lib/collection/hash_set.dart

Issue 18837002: Move toString() to collection classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.collection; 5 part of dart.collection;
6 6
7 /** Common parts of [HashSet] and [LinkedHashSet] implementations. */ 7 /** Common parts of [HashSet] and [LinkedHashSet] implementations. */
8 abstract class _HashSetBase<E> extends IterableBase<E> implements Set<E> { 8 abstract class _HashSetBase<E> extends IterableBase<E> implements Set<E> {
9
9 // Set. 10 // Set.
10 bool containsAll(Iterable<Object> other) { 11 bool containsAll(Iterable<Object> other) {
11 for (Object object in other) { 12 for (Object object in other) {
12 if (!this.contains(object)) return false; 13 if (!this.contains(object)) return false;
13 } 14 }
14 return true; 15 return true;
15 } 16 }
16 17
17 /** Create a new Set of the same type as this. */ 18 /** Create a new Set of the same type as this. */
18 Set _newSet(); 19 Set _newSet();
(...skipping 27 matching lines...) Expand all
46 void retainAll(Iterable objectsToRetain) { 47 void retainAll(Iterable objectsToRetain) {
47 Set retainSet; 48 Set retainSet;
48 if (objectsToRetain is Set) { 49 if (objectsToRetain is Set) {
49 retainSet = objectsToRetain; 50 retainSet = objectsToRetain;
50 } else { 51 } else {
51 retainSet = objectsToRetain.toSet(); 52 retainSet = objectsToRetain.toSet();
52 } 53 }
53 retainWhere(retainSet.contains); 54 retainWhere(retainSet.contains);
54 } 55 }
55 56
56 String toString() => ToString.iterableToString(this); 57 // TODO(zarah) Remove this, and let it be inherited by IterableBase
58 String toString() => IterableMixinWorkaround.toStringIterable(this);
57 } 59 }
58 60
59 /** 61 /**
60 * A [HashSet] is a hash-table based [Set] implementation. 62 * A [HashSet] is a hash-table based [Set] implementation.
61 * 63 *
62 * The elements of a `HashSet` must have consistent [Object.operator==] 64 * The elements of a `HashSet` must have consistent [Object.operator==]
63 * and [Object.hashCode] implementations. This means that the `==` operator 65 * and [Object.hashCode] implementations. This means that the `==` operator
64 * must define a stable equivalence relation on the elements (reflexive, 66 * must define a stable equivalence relation on the elements (reflexive,
65 * anti-symmetric, transitive, and consistent over time), and that `hashCode` 67 * anti-symmetric, transitive, and consistent over time), and that `hashCode`
66 * must be the same for objects that are considered equal by `==`. 68 * must be the same for objects that are considered equal by `==`.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 external void removeAll(Iterable<Object> objectsToRemove); 100 external void removeAll(Iterable<Object> objectsToRemove);
99 101
100 external void removeWhere(bool test(E element)); 102 external void removeWhere(bool test(E element));
101 103
102 external void retainWhere(bool test(E element)); 104 external void retainWhere(bool test(E element));
103 105
104 external void clear(); 106 external void clear();
105 107
106 Set<E> _newSet() => new HashSet<E>(); 108 Set<E> _newSet() => new HashSet<E>();
107 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698