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

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

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/collections.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class ByteBuffer implements List { 5 class ByteBuffer implements List {
6 factory ByteBuffer(int length) { 6 factory ByteBuffer(int length) {
7 return _allocate(length); 7 return _allocate(length);
8 } 8 }
9 9
10 int getInt8(int byteOffset) { 10 int getInt8(int byteOffset) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Collection interface 86 // Collection interface
87 87
88 int get length() { 88 int get length() {
89 return _length(); 89 return _length();
90 } 90 }
91 91
92 bool every(bool f(int element)) { 92 bool every(bool f(int element)) {
93 return Collections.every(this, f); 93 return Collections.every(this, f);
94 } 94 }
95 95
96 Collection map(f(int element)) {
97 return Collections.map(this, new GrowableObjectArray.withCapacity(length), f );
98 }
99
96 Collection filter(bool f(int element)) { 100 Collection filter(bool f(int element)) {
97 return Collections.filter(this, new GrowableObjectArray(), f); 101 return Collections.filter(this, new GrowableObjectArray(), f);
98 } 102 }
99 103
100 void forEach(f(int element)) { 104 void forEach(f(int element)) {
101 Collections.forEach(this, f); 105 Collections.forEach(this, f);
102 } 106 }
103 107
104 bool isEmpty() { 108 bool isEmpty() {
105 return this.length === 0; 109 return this.length === 0;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (!hasNext()) { 217 if (!hasNext()) {
214 throw const NoMoreElementsException(); 218 throw const NoMoreElementsException();
215 } 219 }
216 return _byteBuffer[_pos++]; 220 return _byteBuffer[_pos++];
217 } 221 }
218 222
219 final List _byteBuffer; 223 final List _byteBuffer;
220 final int _length; // Cache byte buffer length for faster access. 224 final int _length; // Cache byte buffer length for faster access.
221 int _pos; 225 int _pos;
222 } 226 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/collections.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698