| 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 _List<E> implements List<E> { | 7 class _List<E> implements List<E> { |
| 8 static final int _classId = (new _List(0))._cid; | 8 static final int _classId = (new _List(0))._cid; |
| 9 | 9 |
| 10 factory _List(length) native "List_allocate"; | 10 factory _List(length) native "List_allocate"; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 if (end < start || end > this.length) { | 71 if (end < start || end > this.length) { |
| 72 throw new RangeError.range(end, start, this.length); | 72 throw new RangeError.range(end, start, this.length); |
| 73 } | 73 } |
| 74 int length = end - start; | 74 int length = end - start; |
| 75 if (length == 0) return; | 75 if (length == 0) return; |
| 76 | 76 |
| 77 if (iterable is _List) { | 77 if (iterable is _List) { |
| 78 _copyFromObjectArray(iterable, skipCount, start, length); | 78 _copyFromObjectArray(iterable, skipCount, start, length); |
| 79 } else { | 79 } else { |
| 80 List otherList; | |
| 81 int otherStart; | |
| 82 if (iterable is List) { | 80 if (iterable is List) { |
| 83 otherList = iterable; | 81 Arrays.copy(iterable, skipCount, this, start, length); |
| 84 otherStart = skipCount; | |
| 85 } else { | 82 } else { |
| 86 otherList = | 83 Iterator it = iterable.iterator; |
| 87 iterable.skip(skipCount).take(length).toList(growable: false); | 84 while (skipCount > 0) { |
| 88 otherStart = 0; | 85 if (!it.moveNext()) return; |
| 86 skipCount--; |
| 87 } |
| 88 for (int i = start; i < end; i++) { |
| 89 if (!it.moveNext()) return; |
| 90 this[i] = it.current; |
| 91 } |
| 89 } | 92 } |
| 90 Arrays.copy(otherList, otherStart, this, start, length); | |
| 91 } | 93 } |
| 92 } | 94 } |
| 93 | 95 |
| 94 void removeRange(int start, int end) { | 96 void removeRange(int start, int end) { |
| 95 throw new UnsupportedError( | 97 throw new UnsupportedError( |
| 96 "Cannot remove range of a non-extendable array"); | 98 "Cannot remove range of a non-extendable array"); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void replaceRange(int start, int end, Iterable<E> iterable) { | 101 void replaceRange(int start, int end, Iterable<E> iterable) { |
| 100 throw new UnsupportedError( | 102 throw new UnsupportedError( |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 560 } |
| 559 _position = _length; | 561 _position = _length; |
| 560 _current = null; | 562 _current = null; |
| 561 return false; | 563 return false; |
| 562 } | 564 } |
| 563 | 565 |
| 564 E get current { | 566 E get current { |
| 565 return _current; | 567 return _current; |
| 566 } | 568 } |
| 567 } | 569 } |
| OLD | NEW |