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

Side by Side Diff: sdk/lib/core/set.dart

Issue 838463002: Change List/Set/Map/Queue.from constructrs to accept any iterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A collection of objects in which each object can occur only once. 8 * A collection of objects in which each object can occur only once.
9 * 9 *
10 * That is, for each object of the element type, the object is either considered 10 * That is, for each object of the element type, the object is either considered
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * Creates an empty identity [Set]. 48 * Creates an empty identity [Set].
49 * 49 *
50 * The created [Set] is a [LinkedHashSet] that uses identity as equality 50 * The created [Set] is a [LinkedHashSet] that uses identity as equality
51 * relation. 51 * relation.
52 * 52 *
53 * The set is equivalent to one created by `new LinkedHashSet<E>.identity()`. 53 * The set is equivalent to one created by `new LinkedHashSet<E>.identity()`.
54 */ 54 */
55 factory Set.identity() = LinkedHashSet<E>.identity; 55 factory Set.identity() = LinkedHashSet<E>.identity;
56 56
57 /** 57 /**
58 * Creates a [Set] that contains all elements of [other]. 58 * Creates a [Set] that contains all of [elements].
59 *
60 * All the [elements] should be assignable to [E].
61 * The `elements` iterable itself can have any type,
62 * so this constructor can be used to down-cast a `Set`, for example as:
63 *
64 * Set<SuperType> superSet = ...;
65 * Set<SubType> subSet =
66 * new Set<SubType>.from(superSet.where((e) => e is SubType));
59 * 67 *
60 * The created [Set] is a [LinkedHashSet]. As such, it considers elements that 68 * The created [Set] is a [LinkedHashSet]. As such, it considers elements that
61 * are equal (using [==]) to be undistinguishable, and requires them to 69 * are equal (using [==]) to be indistinguishable, and requires them to
62 * have a compatible [Object.hashCode] implementation. 70 * have a compatible [Object.hashCode] implementation.
63 * 71 *
64 * The set is equivalent to one created by `new LinkedHashSet<E>.from(other)`. 72 * The set is equivalent to one created by
73 * `new LinkedHashSet<E>.from(elements)`.
65 */ 74 */
66 factory Set.from(Iterable<E> other) = LinkedHashSet<E>.from; 75 factory Set.from(Iterable elements) = LinkedHashSet<E>.from;
67 76
68 /** 77 /**
69 * Provides an iterator that iterates over the elements of this set. 78 * Provides an iterator that iterates over the elements of this set.
70 * 79 *
71 * The order of iteration is defined by the individual `Set` implementation, 80 * The order of iteration is defined by the individual `Set` implementation,
72 * but must be consistent between changes to the set. 81 * but must be consistent between changes to the set.
73 */ 82 */
74 Iterator<E> get iterator; 83 Iterator<E> get iterator;
75 84
76 /** 85 /**
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 /* Creates a [Set] with the same elements and behavior as this `Set`. 179 /* Creates a [Set] with the same elements and behavior as this `Set`.
171 * 180 *
172 * The returned set behaves the same as this set 181 * The returned set behaves the same as this set
173 * with regard to adding and removing elements. 182 * with regard to adding and removing elements.
174 * It initially contains the same elements. 183 * It initially contains the same elements.
175 * If this set specifies an ordering of the elements, 184 * If this set specifies an ordering of the elements,
176 * the returned set will have the same order. 185 * the returned set will have the same order.
177 */ 186 */
178 Set<E> toSet(); 187 Set<E> toSet();
179 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698