| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "dart:_internal"; | 5 import "dart:_internal"; |
| 6 import "dart:collection" show ListBase; | 6 import "dart:collection" show ListBase; |
| 7 import 'dart:math' show Random; | 7 import 'dart:math' show Random; |
| 8 | 8 |
| 9 @patch | 9 @patch |
| 10 class ByteData implements TypedData { | 10 class ByteData implements TypedData { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 while (i > 1) { | 172 while (i > 1) { |
| 173 int pos = random.nextInt(i); | 173 int pos = random.nextInt(i); |
| 174 i -= 1; | 174 i -= 1; |
| 175 var tmp = this[i]; | 175 var tmp = this[i]; |
| 176 this[i] = this[pos]; | 176 this[i] = this[pos]; |
| 177 this[pos] = tmp; | 177 this[pos] = tmp; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 int indexOf(element, [int start = 0]) { | 181 int indexOf(element, [int start = 0]) { |
| 182 return Lists.indexOf(this, element, start, this.length); | 182 if (start >= this.length) { |
| 183 return -1; |
| 184 } else if (start < 0) { |
| 185 start = 0; |
| 186 } |
| 187 for (int i = start; i < this.length; i++) { |
| 188 if (this[i] == element) return i; |
| 189 } |
| 190 return -1; |
| 183 } | 191 } |
| 184 | 192 |
| 185 int lastIndexOf(element, [int start = null]) { | 193 int lastIndexOf(element, [int start = null]) { |
| 186 if (start == null) start = this.length - 1; | 194 if (start == null || start >= this.length) { |
| 187 return Lists.lastIndexOf(this, element, start); | 195 start = this.length - 1; |
| 196 } else if (start < 0) { |
| 197 return -1; |
| 198 } |
| 199 for (int i = start; i >= 0; i--) { |
| 200 if (this[i] == element) return i; |
| 201 } |
| 202 return -1; |
| 188 } | 203 } |
| 189 | 204 |
| 190 void clear() { | 205 void clear() { |
| 191 throw new UnsupportedError("Cannot remove from a fixed-length list"); | 206 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 192 } | 207 } |
| 193 | 208 |
| 194 int removeLast() { | 209 int removeLast() { |
| 195 throw new UnsupportedError("Cannot remove from a fixed-length list"); | 210 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 196 } | 211 } |
| 197 | 212 |
| (...skipping 2863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3061 'BYTES_PER_ELEMENT ($alignment)'); | 3076 'BYTES_PER_ELEMENT ($alignment)'); |
| 3062 } | 3077 } |
| 3063 } | 3078 } |
| 3064 | 3079 |
| 3065 int _defaultIfNull(object, value) { | 3080 int _defaultIfNull(object, value) { |
| 3066 if (object == null) { | 3081 if (object == null) { |
| 3067 return value; | 3082 return value; |
| 3068 } | 3083 } |
| 3069 return object; | 3084 return object; |
| 3070 } | 3085 } |
| OLD | NEW |