| OLD | NEW |
| 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._collection.dev; | 5 part of dart._collection.dev; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. | 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. |
| 9 * | 9 * |
| 10 * All other methods are implemented in terms of [length] and [elementAt], | 10 * All other methods are implemented in terms of [length] and [elementAt], |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (length == 0) throw new StateError("No elements"); | 39 if (length == 0) throw new StateError("No elements"); |
| 40 return elementAt(length - 1); | 40 return elementAt(length - 1); |
| 41 } | 41 } |
| 42 | 42 |
| 43 E get single { | 43 E get single { |
| 44 if (length == 0) throw new StateError("No elements"); | 44 if (length == 0) throw new StateError("No elements"); |
| 45 if (length > 1) throw new StateError("Too many elements"); | 45 if (length > 1) throw new StateError("Too many elements"); |
| 46 return elementAt(0); | 46 return elementAt(0); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool contains(E element) { | 49 bool contains(Object element) { |
| 50 int length = this.length; | 50 int length = this.length; |
| 51 for (int i = 0; i < length; i++) { | 51 for (int i = 0; i < length; i++) { |
| 52 if (elementAt(i) == element) return true; | 52 if (elementAt(i) == element) return true; |
| 53 if (length != this.length) { | 53 if (length != this.length) { |
| 54 throw new ConcurrentModificationError(this); | 54 throw new ConcurrentModificationError(this); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 int get length => 0; | 600 int get length => 0; |
| 601 | 601 |
| 602 E get first { throw new StateError("No elements"); } | 602 E get first { throw new StateError("No elements"); } |
| 603 | 603 |
| 604 E get last { throw new StateError("No elements"); } | 604 E get last { throw new StateError("No elements"); } |
| 605 | 605 |
| 606 E get single { throw new StateError("No elements"); } | 606 E get single { throw new StateError("No elements"); } |
| 607 | 607 |
| 608 E elementAt(int index) { throw new RangeError.value(index); } | 608 E elementAt(int index) { throw new RangeError.value(index); } |
| 609 | 609 |
| 610 bool contains(E element) => false; | 610 bool contains(Object element) => false; |
| 611 | 611 |
| 612 bool every(bool test(E element)) => true; | 612 bool every(bool test(E element)) => true; |
| 613 | 613 |
| 614 bool any(bool test(E element)) => false; | 614 bool any(bool test(E element)) => false; |
| 615 | 615 |
| 616 E firstWhere(bool test(E element), { E orElse() }) { | 616 E firstWhere(bool test(E element), { E orElse() }) { |
| 617 if (orElse != null) return orElse(); | 617 if (orElse != null) return orElse(); |
| 618 throw new StateError("No matching element"); | 618 throw new StateError("No matching element"); |
| 619 } | 619 } |
| 620 | 620 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 | 1035 |
| 1036 static Set setDifference(Set set, Set other, Set result) { | 1036 static Set setDifference(Set set, Set other, Set result) { |
| 1037 for (var element in set) { | 1037 for (var element in set) { |
| 1038 if (!other.contains(element)) { | 1038 if (!other.contains(element)) { |
| 1039 result.add(element); | 1039 result.add(element); |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| 1042 return result; | 1042 return result; |
| 1043 } | 1043 } |
| 1044 } | 1044 } |
| OLD | NEW |