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

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

Issue 288103003: Change Set.toSet to always return a set with the same behavior. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change .clone() to use .toSet(). Update docs. Created 6 years, 7 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 List<E> toList({bool growable: true}) { 53 List<E> toList({bool growable: true}) {
54 List<E> result = growable ? (new List<E>()..length = this.length) 54 List<E> result = growable ? (new List<E>()..length = this.length)
55 : new List<E>(this.length); 55 : new List<E>(this.length);
56 int i = 0; 56 int i = 0;
57 for (E element in this) result[i++] = element; 57 for (E element in this) result[i++] = element;
58 return result; 58 return result;
59 } 59 }
60 60
61 Set<E> cloneEmpty() => _newSet();
62
61 Set<E> toSet() => _newSet()..addAll(this); 63 Set<E> toSet() => _newSet()..addAll(this);
62 64
63 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}'); 65 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}');
64 } 66 }
65 67
66 /** 68 /**
67 * An unordered hash-table based [Set] implementation. 69 * An unordered hash-table based [Set] implementation.
68 * 70 *
69 * The elements of a `HashSet` must have consistent equality 71 * The elements of a `HashSet` must have consistent equality
70 * and hashCode implementations. This means that the equals operation 72 * and hashCode implementations. This means that the equals operation
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 127 }
126 128
127 /** 129 /**
128 * Provides an iterator that iterates over the elements of this set. 130 * Provides an iterator that iterates over the elements of this set.
129 * 131 *
130 * The order of iteration is unspecified, 132 * The order of iteration is unspecified,
131 * but consistent between changes to the set. 133 * but consistent between changes to the set.
132 */ 134 */
133 Iterator<E> get iterator; 135 Iterator<E> get iterator;
134 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698