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

Side by Side Diff: runtime/lib/byte_array.dart

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error. Created 8 years, 1 month 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) 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 patch class Int8List { 5 patch class Int8List {
6 /* patch */ factory Int8List(int length) { 6 /* patch */ factory Int8List(int length) {
7 return new _Int8Array(length); 7 return new _Int8Array(length);
8 } 8 }
9 9
10 /* patch */ factory Int8List.view(ByteArray array, 10 /* patch */ factory Int8List.view(ByteArray array,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 bool contains(element) => Collections.contains(this, element); 126 bool contains(element) => Collections.contains(this, element);
127 127
128 void forEach(void f(element)) { 128 void forEach(void f(element)) {
129 var len = this.length; 129 var len = this.length;
130 for (var i = 0; i < len; i++) { 130 for (var i = 0; i < len; i++) {
131 f(this[i]); 131 f(this[i]);
132 } 132 }
133 } 133 }
134 134
135 Collection mappedBy(f(element)) { 135 Iterable mappedBy(f(element)) {
136 return Collections.mappedBy(this, new List(), f); 136 return new MappedIterable<int, dynamic>(this, f);
137 } 137 }
138 138
139 Dynamic reduce(Dynamic initialValue, 139 Dynamic reduce(Dynamic initialValue,
140 Dynamic combine(Dynamic initialValue, element)) { 140 Dynamic combine(Dynamic initialValue, element)) {
141 return Collections.reduce(this, initialValue, combine); 141 return Collections.reduce(this, initialValue, combine);
142 } 142 }
143 143
144 Collection where(bool f(element)) { 144 Collection where(bool f(element)) {
145 return Collections.where(this, new List(), f); 145 return Collections.where(this, new List(), f);
146 } 146 }
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 int setFloat64(int byteOffset, double value) { 1605 int setFloat64(int byteOffset, double value) {
1606 return _array._setFloat64(_offset + byteOffset, value); 1606 return _array._setFloat64(_offset + byteOffset, value);
1607 } 1607 }
1608 1608
1609 final _ByteArrayBase _array; 1609 final _ByteArrayBase _array;
1610 final int _offset; 1610 final int _offset;
1611 final int _length; 1611 final int _length;
1612 } 1612 }
1613 1613
1614 1614
1615 class _ByteArrayViewBase { 1615 class _ByteArrayViewBase extends Collection<int> {
Ivan Posva 2012/11/26 18:29:09 Please see previous comment about extra costs of e
floitsch 2012/11/28 13:48:23 It is much easier if we only have to implement our
1616 abstract num operator[](int index); 1616 abstract num operator[](int index);
1617 1617
1618 // Methods implementing the Collection interface. 1618 // Methods implementing the Collection interface.
1619 1619
1620 void forEach(void f(element)) { 1620 void forEach(void f(element)) {
1621 var len = this.length; 1621 var len = this.length;
1622 for (var i = 0; i < len; i++) { 1622 for (var i = 0; i < len; i++) {
1623 f(this[i]); 1623 f(this[i]);
1624 } 1624 }
1625 } 1625 }
1626 1626
1627 Collection mappedBy(f(element)) {
1628 return Collections.mappedBy(this, new List(), f);
1629 }
1630
1631 Dynamic reduce(Dynamic initialValue,
1632 Dynamic combine(Dynamic initialValue, element)) {
1633 return Collections.reduce(this, initialValue, combine);
1634 }
1635
1636 Collection where(bool f(element)) {
1637 return Collections.where(this, new List(), f);
1638 }
1639
1640 bool every(bool f(element)) {
1641 return Collections.every(this, f);
1642 }
1643
1644 bool some(bool f(element)) {
1645 return Collections.some(this, f);;
1646 }
1647
1648 bool get isEmpty { 1627 bool get isEmpty {
1649 return this.length == 0; 1628 return this.length == 0;
1650 } 1629 }
1651 1630
1652 abstract int get length; 1631 abstract int get length;
1653 1632
1654 // Methods implementing the List interface. 1633 // Methods implementing the List interface.
1655 1634
1656 set length(newLength) { 1635 set length(newLength) {
1657 throw new UnsupportedError( 1636 throw new UnsupportedError(
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 } 2402 }
2424 _rangeCheck(this.length, start, length); 2403 _rangeCheck(this.length, start, length);
2425 return _array.subByteArray(_offset + start, length); 2404 return _array.subByteArray(_offset + start, length);
2426 } 2405 }
2427 2406
2428 static const int _BYTES_PER_ELEMENT = 8; 2407 static const int _BYTES_PER_ELEMENT = 8;
2429 final ByteArray _array; 2408 final ByteArray _array;
2430 final int _offset; 2409 final int _offset;
2431 final int _length; 2410 final int _length;
2432 } 2411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698