| OLD | NEW |
| 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 | 5 |
| 6 // TODO(srdjan): Use shared array implementation. | 6 // TODO(srdjan): Use shared array implementation. |
| 7 class _ObjectArray<E> implements List<E> { | 7 class _ObjectArray<E> implements List<E> { |
| 8 | 8 |
| 9 factory _ObjectArray(length) native "ObjectArray_allocate"; | 9 factory _ObjectArray(length) native "ObjectArray_allocate"; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 int srcStart, | 22 int srcStart, |
| 23 int dstStart, | 23 int dstStart, |
| 24 int count) | 24 int count) |
| 25 native "ObjectArray_copyFromObjectArray"; | 25 native "ObjectArray_copyFromObjectArray"; |
| 26 | 26 |
| 27 void insert(int index, E element) { | 27 void insert(int index, E element) { |
| 28 throw new UnsupportedError( | 28 throw new UnsupportedError( |
| 29 "Cannot add to a non-extendable array"); | 29 "Cannot add to a non-extendable array"); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void insertAll(int index, Iterable<E> iterable) { |
| 33 throw new UnsupportedError( |
| 34 "Cannot add to a non-extendable array"); |
| 35 } |
| 36 |
| 37 void setAll(int index, Iterable<E> iterable) { |
| 38 IterableMixinWorkaround.setAllList(this, index, iterable); |
| 39 } |
| 40 |
| 32 E removeAt(int index) { | 41 E removeAt(int index) { |
| 33 throw new UnsupportedError( | 42 throw new UnsupportedError( |
| 34 "Cannot remove element of a non-extendable array"); | 43 "Cannot remove element of a non-extendable array"); |
| 35 } | 44 } |
| 36 | 45 |
| 37 void remove(Object element) { | 46 void remove(Object element) { |
| 38 throw new UnsupportedError( | 47 throw new UnsupportedError( |
| 39 "Cannot remove element of a non-extendable array"); | 48 "Cannot remove element of a non-extendable array"); |
| 40 } | 49 } |
| 41 | 50 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 88 } |
| 80 Arrays.copy(otherList, otherStart, this, start, length); | 89 Arrays.copy(otherList, otherStart, this, start, length); |
| 81 } | 90 } |
| 82 } | 91 } |
| 83 | 92 |
| 84 void removeRange(int start, int end) { | 93 void removeRange(int start, int end) { |
| 85 throw new UnsupportedError( | 94 throw new UnsupportedError( |
| 86 "Cannot remove range of a non-extendable array"); | 95 "Cannot remove range of a non-extendable array"); |
| 87 } | 96 } |
| 88 | 97 |
| 98 void replaceRange(int start, int end, Iterable<E> iterable) { |
| 99 throw new UnsupportedError( |
| 100 "Cannot remove range of a non-extendable array"); |
| 101 } |
| 102 |
| 103 void fillRange(int start, int end, [E fillValue]) { |
| 104 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue); |
| 105 } |
| 106 |
| 89 List<E> sublist(int start, [int end]) { | 107 List<E> sublist(int start, [int end]) { |
| 90 Arrays.indicesCheck(this, start, end); | 108 Arrays.indicesCheck(this, start, end); |
| 91 if (end == null) end = this.length; | 109 if (end == null) end = this.length; |
| 92 int length = end - start; | 110 int length = end - start; |
| 93 if (start == end) return []; | 111 if (start == end) return []; |
| 94 List list = new _GrowableObjectArray<E>.withCapacity(length); | 112 List list = new _GrowableObjectArray<E>.withCapacity(length); |
| 95 list.length = length; | 113 list.length = length; |
| 96 Arrays.copy(this, start, list, 0, length); | 114 Arrays.copy(this, start, list, 0, length); |
| 97 return list; | 115 return list; |
| 98 } | 116 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 "Cannot modify an immutable array"); | 288 "Cannot modify an immutable array"); |
| 271 } | 289 } |
| 272 | 290 |
| 273 int get length native "ObjectArray_getLength"; | 291 int get length native "ObjectArray_getLength"; |
| 274 | 292 |
| 275 void insert(int index, E element) { | 293 void insert(int index, E element) { |
| 276 throw new UnsupportedError( | 294 throw new UnsupportedError( |
| 277 "Cannot add to an immutable array"); | 295 "Cannot add to an immutable array"); |
| 278 } | 296 } |
| 279 | 297 |
| 298 void insertAll(int index, Iterable<E> iterable) { |
| 299 throw new UnsupportedError( |
| 300 "Cannot add to an immutable array"); |
| 301 } |
| 302 |
| 303 void setAll(int index, Iterable<E> iterable) { |
| 304 throw new UnsupportedError( |
| 305 "Cannot modify an immutable array"); |
| 306 } |
| 307 |
| 280 E removeAt(int index) { | 308 E removeAt(int index) { |
| 281 throw new UnsupportedError( | 309 throw new UnsupportedError( |
| 282 "Cannot modify an immutable array"); | 310 "Cannot modify an immutable array"); |
| 283 } | 311 } |
| 284 | 312 |
| 285 void remove(Object element) { | 313 void remove(Object element) { |
| 286 throw new UnsupportedError( | 314 throw new UnsupportedError( |
| 287 "Cannot modify an immutable array"); | 315 "Cannot modify an immutable array"); |
| 288 } | 316 } |
| 289 | 317 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 305 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 333 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
| 306 throw new UnsupportedError( | 334 throw new UnsupportedError( |
| 307 "Cannot modify an immutable array"); | 335 "Cannot modify an immutable array"); |
| 308 } | 336 } |
| 309 | 337 |
| 310 void removeRange(int start, int end) { | 338 void removeRange(int start, int end) { |
| 311 throw new UnsupportedError( | 339 throw new UnsupportedError( |
| 312 "Cannot remove range of an immutable array"); | 340 "Cannot remove range of an immutable array"); |
| 313 } | 341 } |
| 314 | 342 |
| 343 void fillRange(int start, int end, [E fillValue]) { |
| 344 throw new UnsupportedError( |
| 345 "Cannot modify an immutable array"); |
| 346 } |
| 347 |
| 348 void replaceRange(int start, int end, Iterable<E> iterable) { |
| 349 throw new UnsupportedError( |
| 350 "Cannot modify an immutable array"); |
| 351 } |
| 352 |
| 315 List<E> sublist(int start, [int end]) { | 353 List<E> sublist(int start, [int end]) { |
| 316 Arrays.indicesCheck(this, start, end); | 354 Arrays.indicesCheck(this, start, end); |
| 317 if (end == null) end = this.length; | 355 if (end == null) end = this.length; |
| 318 int length = end - start; | 356 int length = end - start; |
| 319 if (start == end) return []; | 357 if (start == end) return []; |
| 320 List list = new List<E>(); | 358 List list = new List<E>(); |
| 321 list.length = length; | 359 list.length = length; |
| 322 Arrays.copy(this, start, list, 0, length); | 360 Arrays.copy(this, start, list, 0, length); |
| 323 return list; | 361 return list; |
| 324 } | 362 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 543 } |
| 506 _position = _length; | 544 _position = _length; |
| 507 _current = null; | 545 _current = null; |
| 508 return false; | 546 return false; |
| 509 } | 547 } |
| 510 | 548 |
| 511 E get current { | 549 E get current { |
| 512 return _current; | 550 return _current; |
| 513 } | 551 } |
| 514 } | 552 } |
| OLD | NEW |