Index: sdk/lib/_internal/compiler/implementation/lib/js_array.dart |
=================================================================== |
--- sdk/lib/_internal/compiler/implementation/lib/js_array.dart (revision 15076) |
+++ sdk/lib/_internal/compiler/implementation/lib/js_array.dart (working copy) |
@@ -80,4 +80,84 @@ |
if (length < 0) throw new ArgumentError(length); |
return JS('List', r'#.slice(#, #)', this, start, end); |
} |
+ |
+ void insertRange(int start, int length, [E initialValue]) { |
+ return listInsertRange(this, start, length, initialValue); |
+ } |
+ |
+ E get last => this[length - 1]; |
+ |
+ E get first => this[0]; |
+ |
+ void removeRange(int start, int length) { |
+ checkGrowable(this, 'removeRange'); |
+ if (length == 0) { |
+ return; |
+ } |
+ checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
+ checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
+ if (start is !int) throw new ArgumentError(start); |
+ if (length is !int) throw new ArgumentError(length); |
+ if (length < 0) throw new ArgumentError(length); |
+ var receiverLength = this.length; |
+ if (start < 0 || start >= receiverLength) { |
+ throw new RangeError.value(start); |
+ } |
+ if (start + length > receiverLength) { |
+ throw new RangeError.value(start + length); |
+ } |
+ Arrays.copy(this, |
+ start + length, |
+ this, |
+ start, |
+ receiverLength - length - start); |
+ this.length = receiverLength - length; |
+ } |
+ |
+ void setRange(int start, int length, List<E> from, [int startFrom = 0]) { |
+ checkMutable(this, 'indexed set'); |
+ if (length == 0) return; |
+ checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
+ checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
+ checkNull(from); // TODO(ahe): This is not specified but co19 tests it. |
+ checkNull(startFrom); // TODO(ahe): This is not specified but co19 tests it. |
+ if (start is !int) throw new ArgumentError(start); |
+ if (length is !int) throw new ArgumentError(length); |
+ if (startFrom is !int) throw new ArgumentError(startFrom); |
+ if (length < 0) throw new ArgumentError(length); |
+ if (start < 0) throw new RangeError.value(start); |
+ if (start + length > this.length) { |
+ throw new RangeError.value(start + length); |
+ } |
+ |
+ Arrays.copy(from, startFrom, this, start, length); |
+ } |
+ |
+ bool some(bool f(E element)) => Collections.some(this, f); |
+ |
+ bool every(bool f(E element)) => Collections.every(this, f); |
+ |
+ void sort([Comparator<E> compare = Comparable.compare]) { |
+ checkMutable(this, 'sort'); |
+ coreSort(this, compare); |
+ } |
+ |
+ int indexOf(E element, [int start = 0]) { |
+ if (start is !int) throw new ArgumentError(start); |
+ return Arrays.indexOf(this, element, start, length); |
+ } |
+ |
+ int lastIndexOf(E element, [int start]) { |
+ if (start == null) start = this.length - 1; |
+ return Arrays.lastIndexOf(this, element, start); |
+ } |
+ |
+ bool contains(E other) { |
+ for (int i = 0; i < length; i++) { |
+ if (other == this[i]) return true; |
+ } |
+ return false; |
+ } |
+ |
+ bool get isEmpty => length == 0; |
} |