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

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

Issue 12544024: Make Set.containsAll accept Iterable. Deprecate Set.isSubsetOf. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | sdk/lib/collection/hash_set.dart » ('j') | tools/dom/src/CssClassSet.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 7 /**
8 * This class provides default implementations for Iterables (including Lists). 8 * This class provides default implementations for Iterables (including Lists).
9 * 9 *
10 * Once Dart receives Mixins it will be replaced with mixin classes. 10 * Once Dart receives Mixins it will be replaced with mixin classes.
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 throw new RangeError.value(start + length); 375 throw new RangeError.value(start + length);
376 } 376 }
377 377
378 Arrays.copy(from, startFrom, list, start, length); 378 Arrays.copy(from, startFrom, list, start, length);
379 } 379 }
380 380
381 static Map<int, dynamic> asMapList(List l) { 381 static Map<int, dynamic> asMapList(List l) {
382 return new ListMapView(l); 382 return new ListMapView(l);
383 } 383 }
384 384
385 static bool isSubsetOfSet(Set set, Set other) { 385 static bool setContainsAll(Set set, Iterable other) {
386 if (set.length > other.length) return false; 386 for (var element in other) {
387 for (var element in set) { 387 if (!set.contains(element)) return false;
388 if (!other.contains(element)) return false;
389 } 388 }
390 return true; 389 return true;
391 } 390 }
392 391
393
394 static Set setIntersection(Set set, Set other, Set result) { 392 static Set setIntersection(Set set, Set other, Set result) {
395 Set smaller; 393 Set smaller;
396 Set larger; 394 Set larger;
397 if (set.length < other.length) { 395 if (set.length < other.length) {
398 smaller = set; 396 smaller = set;
399 larger = other; 397 larger = other;
400 } else { 398 } else {
401 smaller = other; 399 smaller = other;
402 larger = set; 400 larger = set;
403 } 401 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 * The source of the elements may be a [List] or any [Iterable] with 434 * The source of the elements may be a [List] or any [Iterable] with
437 * efficient [Iterable.length] and [Iterable.elementAt]. 435 * efficient [Iterable.length] and [Iterable.elementAt].
438 */ 436 */
439 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { 437 class UnmodifiableListView<E> extends UnmodifiableListBase<E> {
440 Iterable<E> _source; 438 Iterable<E> _source;
441 /** Create an unmodifiable list backed by [source]. */ 439 /** Create an unmodifiable list backed by [source]. */
442 UnmodifiableListView(Iterable<E> source) : _source = source; 440 UnmodifiableListView(Iterable<E> source) : _source = source;
443 int get length => _source.length; 441 int get length => _source.length;
444 E operator[](int index) => _source.elementAt(index); 442 E operator[](int index) => _source.elementAt(index);
445 } 443 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/collection/hash_set.dart » ('j') | tools/dom/src/CssClassSet.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698