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

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

Issue 26481002: Change the toString method of IterableBase/IterableMixin to show some elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adapted other test too. 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 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
10 // Set. 10 // Set.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 Set retainSet = _newSet(); 50 Set retainSet = _newSet();
51 for (Object o in objectsToRetain) { 51 for (Object o in objectsToRetain) {
52 if (isValidKey(o)) { 52 if (isValidKey(o)) {
53 retainSet.add(o); 53 retainSet.add(o);
54 } 54 }
55 } 55 }
56 retainWhere(retainSet.contains); 56 retainWhere(retainSet.contains);
57 } 57 }
58 58
59 List<E> toList({bool growable: true}) { 59 List<E> toList({bool growable: true}) {
60 List<E> result = new List<E>()..length = this.length; 60 List<E> result = growable ? (new List<E>()..length = this.length)
floitsch 2013/10/11 09:29:43 I would have preferred if this was in a separate C
Lasse Reichstein Nielsen 2013/10/11 20:25:37 Kept.
61 : new List<E>(this.length);
61 int i = 0; 62 int i = 0;
62 for (E element in this) result[i++] = element; 63 for (E element in this) result[i++] = element;
63 return result; 64 return result;
64 } 65 }
65 66
66 Set<E> toSet() => _newSet()..addAll(this); 67 Set<E> toSet() => _newSet()..addAll(this);
67 68
68 // TODO(zarah) Remove this, and let it be inherited by IterableBase
69 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}'); 69 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}');
70 } 70 }
71 71
72 /** 72 /**
73 * A [HashSet] is a hash-table based [Set] implementation. 73 * A [HashSet] is a hash-table based [Set] implementation.
74 * 74 *
75 * The elements of a `HashSet` must have consistent equality 75 * The elements of a `HashSet` must have consistent equality
76 * and hashCode implementations. This means that the equals operation 76 * and hashCode implementations. This means that the equals operation
77 * must define a stable equivalence relation on the elements (reflexive, 77 * must define a stable equivalence relation on the elements (reflexive,
78 * anti-symmetric, transitive, and consistent over time), and that the hashCode 78 * anti-symmetric, transitive, and consistent over time), and that the hashCode
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 /** 122 /**
123 * Create a hash set containing the elements of [iterable]. 123 * Create a hash set containing the elements of [iterable].
124 * 124 *
125 * Creates a hash set as by `new HashSet<E>()` and adds each element of 125 * Creates a hash set as by `new HashSet<E>()` and adds each element of
126 * `iterable` to this set in the order they are iterated. 126 * `iterable` to this set in the order they are iterated.
127 */ 127 */
128 factory HashSet.from(Iterable<E> iterable) { 128 factory HashSet.from(Iterable<E> iterable) {
129 return new HashSet<E>()..addAll(iterable); 129 return new HashSet<E>()..addAll(iterable);
130 } 130 }
131 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698