| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |