OLD | NEW |
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 Loading... |
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 setContainsAll(Set set, Iterable other) { | 385 static bool isSubsetOfSet(Set set, Set other) { |
386 for (var element in other) { | 386 if (set.length > other.length) return false; |
387 if (!set.contains(element)) return false; | 387 for (var element in set) { |
| 388 if (!other.contains(element)) return false; |
388 } | 389 } |
389 return true; | 390 return true; |
390 } | 391 } |
391 | 392 |
| 393 |
392 static Set setIntersection(Set set, Set other, Set result) { | 394 static Set setIntersection(Set set, Set other, Set result) { |
393 Set smaller; | 395 Set smaller; |
394 Set larger; | 396 Set larger; |
395 if (set.length < other.length) { | 397 if (set.length < other.length) { |
396 smaller = set; | 398 smaller = set; |
397 larger = other; | 399 larger = other; |
398 } else { | 400 } else { |
399 smaller = other; | 401 smaller = other; |
400 larger = set; | 402 larger = set; |
401 } | 403 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 * The source of the elements may be a [List] or any [Iterable] with | 436 * The source of the elements may be a [List] or any [Iterable] with |
435 * efficient [Iterable.length] and [Iterable.elementAt]. | 437 * efficient [Iterable.length] and [Iterable.elementAt]. |
436 */ | 438 */ |
437 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { | 439 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { |
438 Iterable<E> _source; | 440 Iterable<E> _source; |
439 /** Create an unmodifiable list backed by [source]. */ | 441 /** Create an unmodifiable list backed by [source]. */ |
440 UnmodifiableListView(Iterable<E> source) : _source = source; | 442 UnmodifiableListView(Iterable<E> source) : _source = source; |
441 int get length => _source.length; | 443 int get length => _source.length; |
442 E operator[](int index) => _source.elementAt(index); | 444 E operator[](int index) => _source.elementAt(index); |
443 } | 445 } |
OLD | NEW |