Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Unified Diff: test/codegen/expect/dart/collection.js

Issue 1016003003: sort classes in dependency order, or load lazily if needed, fixes #78 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/codegen/expect/dart/collection.js
diff --git a/test/codegen/expect/dart/collection.js b/test/codegen/expect/dart/collection.js
index 465acee6792dc34eb971fd2720b3bf2894a4b199..459e2a05116b508f704097760e301c8d1d6c0fe8 100644
--- a/test/codegen/expect/dart/collection.js
+++ b/test/codegen/expect/dart/collection.js
@@ -17,7 +17,7 @@ var collection;
}
return UnmodifiableListView;
});
- let UnmodifiableListView = UnmodifiableListView$(dart.dynamic);
+ dart.defineLazyClassGeneric(exports, 'UnmodifiableListView', {get: UnmodifiableListView$});
// Function _defaultEquals: (dynamic, dynamic) → bool
function _defaultEquals(a, b) {
return dart.equals(a, b);
@@ -87,6 +87,261 @@ var collection;
});
let HashMap = HashMap$(dart.dynamic, dart.dynamic);
let _newSet = Symbol('_newSet');
+ let SetMixin$ = dart.generic(function(E) {
+ class SetMixin extends core.Object {
+ get isEmpty() {
+ return this.length === 0;
+ }
+ get isNotEmpty() {
+ return this.length !== 0;
+ }
+ clear() {
+ this.removeAll(this.toList());
+ }
+ addAll(elements) {
+ for (let element of elements)
+ this.add(element);
+ }
+ removeAll(elements) {
+ for (let element of elements)
+ this.remove(element);
+ }
+ retainAll(elements) {
+ let toRemove = this.toSet();
+ for (let o of elements) {
+ toRemove.remove(o);
+ }
+ this.removeAll(toRemove);
+ }
+ removeWhere(test) {
+ let toRemove = new List.from([]);
+ for (let element of this) {
+ if (test(element))
+ toRemove.add(element);
+ }
+ this.removeAll(dart.as(toRemove, core.Iterable$(core.Object)));
+ }
+ retainWhere(test) {
+ let toRemove = new List.from([]);
+ for (let element of this) {
+ if (!dart.notNull(test(element)))
+ toRemove.add(element);
+ }
+ this.removeAll(dart.as(toRemove, core.Iterable$(core.Object)));
+ }
+ containsAll(other) {
+ for (let o of other) {
+ if (!dart.notNull(this.contains(o)))
+ return false;
+ }
+ return true;
+ }
+ union(other) {
+ return ((_) => {
+ _.addAll(other);
+ return _;
+ }).bind(this)(this.toSet());
+ }
+ intersection(other) {
+ let result = this.toSet();
+ for (let element of this) {
+ if (!dart.notNull(other.contains(element)))
+ result.remove(element);
+ }
+ return result;
+ }
+ difference(other) {
+ let result = this.toSet();
+ for (let element of this) {
+ if (other.contains(element))
+ result.remove(element);
+ }
+ return result;
+ }
+ toList(opt$) {
+ let growable = opt$.growable === void 0 ? true : opt$.growable;
+ let result = growable ? ((_) => {
+ _.length = this.length;
+ return _;
+ }).bind(this)(new core.List()) : new core.List(this.length);
+ let i = 0;
+ for (let element of this)
+ result.set((($tmp) => i = dart.notNull($tmp) + 1, $tmp)(i), element);
+ return result;
+ }
+ map(f) {
+ return new _internal.EfficientLengthMappedIterable(this, f);
+ }
+ get single() {
+ if (dart.notNull(this.length) > 1)
+ throw _internal.IterableElementError.tooMany();
+ let it = this.iterator;
+ if (!dart.notNull(it.moveNext()))
+ throw _internal.IterableElementError.noElement();
+ let result = dart.as(it.current, E);
+ return result;
+ }
+ toString() {
+ return IterableBase.iterableToFullString(this, '{', '}');
+ }
+ where(f) {
+ return new _internal.WhereIterable(this, f);
+ }
+ expand(f) {
+ return new _internal.ExpandIterable(this, f);
+ }
+ forEach(f) {
+ for (let element of this)
+ f(element);
+ }
+ reduce(combine) {
+ let iterator = this.iterator;
+ if (!dart.notNull(iterator.moveNext())) {
+ throw _internal.IterableElementError.noElement();
+ }
+ let value = iterator.current;
+ while (iterator.moveNext()) {
+ value = combine(value, iterator.current);
+ }
+ return value;
+ }
+ fold(initialValue, combine) {
+ let value = initialValue;
+ for (let element of this)
+ value = combine(value, element);
+ return value;
+ }
+ every(f) {
+ for (let element of this) {
+ if (!dart.notNull(f(element)))
+ return false;
+ }
+ return true;
+ }
+ join(separator) {
+ if (separator === void 0)
+ separator = "";
+ let iterator = this.iterator;
+ if (!dart.notNull(iterator.moveNext()))
+ return "";
+ let buffer = new core.StringBuffer();
+ if (dart.notNull(separator === null) || dart.notNull(dart.equals(separator, ""))) {
+ do {
+ buffer.write(`${iterator.current}`);
+ } while (iterator.moveNext());
+ } else {
+ buffer.write(`${iterator.current}`);
+ while (iterator.moveNext()) {
+ buffer.write(separator);
+ buffer.write(`${iterator.current}`);
+ }
+ }
+ return buffer.toString();
+ }
+ any(test) {
+ for (let element of this) {
+ if (test(element))
+ return true;
+ }
+ return false;
+ }
+ take(n) {
+ return new _internal.TakeIterable(this, n);
+ }
+ takeWhile(test) {
+ return new _internal.TakeWhileIterable(this, test);
+ }
+ skip(n) {
+ return new _internal.SkipIterable(this, n);
+ }
+ skipWhile(test) {
+ return new _internal.SkipWhileIterable(this, test);
+ }
+ get first() {
+ let it = this.iterator;
+ if (!dart.notNull(it.moveNext())) {
+ throw _internal.IterableElementError.noElement();
+ }
+ return dart.as(it.current, E);
+ }
+ get last() {
+ let it = this.iterator;
+ if (!dart.notNull(it.moveNext())) {
+ throw _internal.IterableElementError.noElement();
+ }
+ let result = null;
+ do {
+ result = dart.as(it.current, E);
+ } while (it.moveNext());
+ return result;
+ }
+ firstWhere(test, opt$) {
+ let orElse = opt$.orElse === void 0 ? null : opt$.orElse;
+ for (let element of this) {
+ if (test(element))
+ return element;
+ }
+ if (orElse !== null)
+ return orElse();
+ throw _internal.IterableElementError.noElement();
+ }
+ lastWhere(test, opt$) {
+ let orElse = opt$.orElse === void 0 ? null : opt$.orElse;
+ let result = null;
+ let foundMatching = false;
+ for (let element of this) {
+ if (test(element)) {
+ result = element;
+ foundMatching = true;
+ }
+ }
+ if (foundMatching)
+ return result;
+ if (orElse !== null)
+ return orElse();
+ throw _internal.IterableElementError.noElement();
+ }
+ singleWhere(test) {
+ let result = null;
+ let foundMatching = false;
+ for (let element of this) {
+ if (test(element)) {
+ if (foundMatching) {
+ throw _internal.IterableElementError.tooMany();
+ }
+ result = element;
+ foundMatching = true;
+ }
+ }
+ if (foundMatching)
+ return result;
+ throw _internal.IterableElementError.noElement();
+ }
+ elementAt(index) {
+ if (!(typeof index == number))
+ throw new core.ArgumentError.notNull("index");
+ core.RangeError.checkNotNegative(index, "index");
+ let elementIndex = 0;
+ for (let element of this) {
+ if (index === elementIndex)
+ return element;
+ elementIndex = dart.notNull(elementIndex) + 1;
+ }
+ throw new core.RangeError.index(index, this, "index", null, elementIndex);
+ }
+ }
+ return SetMixin;
+ });
+ let SetMixin = SetMixin$(dart.dynamic);
+ let SetBase$ = dart.generic(function(E) {
+ class SetBase extends SetMixin$(E) {
+ static setToString(set) {
+ return IterableBase.iterableToFullString(set, '{', '}');
+ }
+ }
+ return SetBase;
+ });
+ let SetBase = SetBase$(dart.dynamic);
let _HashSetBase$ = dart.generic(function(E) {
class _HashSetBase extends SetBase$(E) {
difference(other) {
@@ -1015,15 +1270,6 @@ var collection;
return LinkedListEntry;
});
let LinkedListEntry = LinkedListEntry$(dart.dynamic);
- let ListBase$ = dart.generic(function(E) {
- class ListBase extends dart.mixin(core.Object, ListMixin$(E)) {
- static listToString(list) {
- return IterableBase.iterableToFullString(list, '[', ']');
- }
- }
- return ListBase;
- });
- let ListBase = ListBase$(dart.dynamic);
let _filter = Symbol('_filter');
let ListMixin$ = dart.generic(function(E) {
class ListMixin extends core.Object {
@@ -1475,12 +1721,15 @@ var collection;
return ListMixin;
});
let ListMixin = ListMixin$(dart.dynamic);
- let MapBase$ = dart.generic(function(K, V) {
- class MapBase extends dart.mixin(MapMixin$(K, V)) {
+ let ListBase$ = dart.generic(function(E) {
+ class ListBase extends dart.mixin(core.Object, ListMixin$(E)) {
+ static listToString(list) {
+ return IterableBase.iterableToFullString(list, '[', ']');
+ }
}
- return MapBase;
+ return ListBase;
});
- let MapBase = MapBase$(dart.dynamic, dart.dynamic);
+ let ListBase = ListBase$(dart.dynamic);
let MapMixin$ = dart.generic(function(K, V) {
class MapMixin extends core.Object {
forEach(action) {
@@ -1528,6 +1777,33 @@ var collection;
return MapMixin;
});
let MapMixin = MapMixin$(dart.dynamic, dart.dynamic);
+ let MapBase$ = dart.generic(function(K, V) {
+ class MapBase extends dart.mixin(MapMixin$(K, V)) {
+ }
+ return MapBase;
+ });
+ let MapBase = MapBase$(dart.dynamic, dart.dynamic);
+ let _UnmodifiableMapMixin$ = dart.generic(function(K, V) {
+ class _UnmodifiableMapMixin extends core.Object {
+ set(key, value) {
+ throw new core.UnsupportedError("Cannot modify unmodifiable map");
+ }
+ addAll(other) {
+ throw new core.UnsupportedError("Cannot modify unmodifiable map");
+ }
+ clear() {
+ throw new core.UnsupportedError("Cannot modify unmodifiable map");
+ }
+ remove(key) {
+ throw new core.UnsupportedError("Cannot modify unmodifiable map");
+ }
+ putIfAbsent(key, ifAbsent) {
+ throw new core.UnsupportedError("Cannot modify unmodifiable map");
+ }
+ }
+ return _UnmodifiableMapMixin;
+ });
+ let _UnmodifiableMapMixin = _UnmodifiableMapMixin$(dart.dynamic, dart.dynamic);
let UnmodifiableMapBase$ = dart.generic(function(K, V) {
class UnmodifiableMapBase extends dart.mixin(_UnmodifiableMapMixin$(K, V)) {
}
@@ -1589,27 +1865,6 @@ var collection;
return _MapBaseValueIterator;
});
let _MapBaseValueIterator = _MapBaseValueIterator$(dart.dynamic);
- let _UnmodifiableMapMixin$ = dart.generic(function(K, V) {
- class _UnmodifiableMapMixin extends core.Object {
- set(key, value) {
- throw new core.UnsupportedError("Cannot modify unmodifiable map");
- }
- addAll(other) {
- throw new core.UnsupportedError("Cannot modify unmodifiable map");
- }
- clear() {
- throw new core.UnsupportedError("Cannot modify unmodifiable map");
- }
- remove(key) {
- throw new core.UnsupportedError("Cannot modify unmodifiable map");
- }
- putIfAbsent(key, ifAbsent) {
- throw new core.UnsupportedError("Cannot modify unmodifiable map");
- }
- }
- return _UnmodifiableMapMixin;
- });
- let _UnmodifiableMapMixin = _UnmodifiableMapMixin$(dart.dynamic, dart.dynamic);
let MapView$ = dart.generic(function(K, V) {
class MapView extends core.Object {
MapView(map) {
@@ -2125,461 +2380,206 @@ var collection;
} else {
let preSpace = dart.notNull(addCount) - dart.notNull(endSpace);
this[_table].setRange(this[_tail], dart.notNull(this[_tail]) + dart.notNull(endSpace), dart.as(list, core.Iterable$(E)), 0);
- this[_table].setRange(0, preSpace, dart.as(list, core.Iterable$(E)), endSpace);
- this[_tail] = preSpace;
- }
- }
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- } else {
- for (let element of elements)
- this[_add](element);
- }
- }
- remove(object) {
- for (let i = this[_head]; i !== this[_tail]; i = dart.notNull(i) + 1 & dart.notNull(this[_table].length) - 1) {
- let element = this[_table].get(i);
- if (dart.equals(element, object)) {
- this[_remove](i);
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- return true;
- }
- }
- return false;
- }
- [_filterWhere](test, removeMatching) {
- let index = this[_head];
- let modificationCount = this[_modificationCount];
- let i = this[_head];
- while (i !== this[_tail]) {
- let element = this[_table].get(i);
- let remove = core.identical(removeMatching, test(element));
- this[_checkModification](modificationCount);
- if (remove) {
- i = this[_remove](i);
- modificationCount = this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- } else {
- i = dart.notNull(i) + 1 & dart.notNull(this[_table].length) - 1;
- }
- }
- }
- removeWhere(test) {
- this[_filterWhere](test, true);
- }
- retainWhere(test) {
- this[_filterWhere](test, false);
- }
- clear() {
- if (this[_head] !== this[_tail]) {
- for (let i = this[_head]; i !== this[_tail]; i = dart.notNull(i) + 1 & dart.notNull(this[_table].length) - 1) {
- this[_table].set(i, null);
- }
- this[_head] = this[_tail] = 0;
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- }
- }
- toString() {
- return IterableBase.iterableToFullString(this, "{", "}");
- }
- addLast(element) {
- this[_add](element);
- }
- addFirst(element) {
- this[_head] = dart.notNull(this[_head]) - 1 & dart.notNull(this[_table].length) - 1;
- this[_table].set(this[_head], element);
- if (this[_head] === this[_tail])
- this[_grow]();
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- }
- removeFirst() {
- if (this[_head] === this[_tail])
- throw _internal.IterableElementError.noElement();
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- let result = this[_table].get(this[_head]);
- this[_table].set(this[_head], null);
- this[_head] = dart.notNull(this[_head]) + 1 & dart.notNull(this[_table].length) - 1;
- return result;
- }
- removeLast() {
- if (this[_head] === this[_tail])
- throw _internal.IterableElementError.noElement();
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- this[_tail] = dart.notNull(this[_tail]) - 1 & dart.notNull(this[_table].length) - 1;
- let result = this[_table].get(this[_tail]);
- this[_table].set(this[_tail], null);
- return result;
- }
- static [_isPowerOf2](number) {
- return (dart.notNull(number) & dart.notNull(number) - 1) === 0;
- }
- static [_nextPowerOf2](number) {
- dart.assert(dart.notNull(number) > 0);
- number = (dart.notNull(number) << 1) - 1;
- for (;;) {
- let nextNumber = dart.notNull(number) & dart.notNull(number) - 1;
- if (nextNumber === 0)
- return number;
- number = nextNumber;
- }
- }
- [_checkModification](expectedModificationCount) {
- if (expectedModificationCount !== this[_modificationCount]) {
- throw new core.ConcurrentModificationError(this);
- }
- }
- [_add](element) {
- this[_table].set(this[_tail], element);
- this[_tail] = dart.notNull(this[_tail]) + 1 & dart.notNull(this[_table].length) - 1;
- if (this[_head] === this[_tail])
- this[_grow]();
- this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
- }
- [_remove](offset) {
- let mask = dart.notNull(this[_table].length) - 1;
- let startDistance = dart.notNull(offset) - dart.notNull(this[_head]) & dart.notNull(mask);
- let endDistance = dart.notNull(this[_tail]) - dart.notNull(offset) & dart.notNull(mask);
- if (dart.notNull(startDistance) < dart.notNull(endDistance)) {
- let i = offset;
- while (i !== this[_head]) {
- let prevOffset = dart.notNull(i) - 1 & dart.notNull(mask);
- this[_table].set(i, this[_table].get(prevOffset));
- i = prevOffset;
- }
- this[_table].set(this[_head], null);
- this[_head] = dart.notNull(this[_head]) + 1 & dart.notNull(mask);
- return dart.notNull(offset) + 1 & dart.notNull(mask);
- } else {
- this[_tail] = dart.notNull(this[_tail]) - 1 & dart.notNull(mask);
- let i = offset;
- while (i !== this[_tail]) {
- let nextOffset = dart.notNull(i) + 1 & dart.notNull(mask);
- this[_table].set(i, this[_table].get(nextOffset));
- i = nextOffset;
- }
- this[_table].set(this[_tail], null);
- return offset;
- }
- }
- [_grow]() {
- let newTable = new core.List(dart.notNull(this[_table].length) * 2);
- let split = dart.notNull(this[_table].length) - dart.notNull(this[_head]);
- newTable.setRange(0, split, this[_table], this[_head]);
- newTable.setRange(split, dart.notNull(split) + dart.notNull(this[_head]), this[_table], 0);
- this[_head] = 0;
- this[_tail] = this[_table].length;
- this[_table] = newTable;
- }
- [_writeToList](target) {
- dart.assert(dart.notNull(target.length) >= dart.notNull(this.length));
- if (dart.notNull(this[_head]) <= dart.notNull(this[_tail])) {
- let length = dart.notNull(this[_tail]) - dart.notNull(this[_head]);
- target.setRange(0, length, this[_table], this[_head]);
- return length;
- } else {
- let firstPartSize = dart.notNull(this[_table].length) - dart.notNull(this[_head]);
- target.setRange(0, firstPartSize, this[_table], this[_head]);
- target.setRange(firstPartSize, dart.notNull(firstPartSize) + dart.notNull(this[_tail]), this[_table], 0);
- return dart.notNull(this[_tail]) + dart.notNull(firstPartSize);
- }
- }
- [_preGrow](newElementCount) {
- dart.assert(dart.notNull(newElementCount) >= dart.notNull(this.length));
- newElementCount = dart.notNull(newElementCount) >> 1;
- let newCapacity = _nextPowerOf2(newElementCount);
- let newTable = new core.List(newCapacity);
- this[_tail] = this[_writeToList](newTable);
- this[_table] = newTable;
- this[_head] = 0;
- }
- }
- dart.defineNamedConstructor(ListQueue, 'from');
- ListQueue._INITIAL_CAPACITY = 8;
- return ListQueue;
- });
- let ListQueue = ListQueue$(dart.dynamic);
- let _queue = Symbol('_queue');
- let _end = Symbol('_end');
- let _position = Symbol('_position');
- let _ListQueueIterator$ = dart.generic(function(E) {
- class _ListQueueIterator extends core.Object {
- _ListQueueIterator(queue) {
- this[_queue] = queue;
- this[_end] = queue[_tail];
- this[_modificationCount] = queue[_modificationCount];
- this[_position] = queue[_head];
- this[_current] = null;
- }
- get current() {
- return this[_current];
- }
- moveNext() {
- this[_queue]._checkModification(this[_modificationCount]);
- if (this[_position] === this[_end]) {
- this[_current] = null;
- return false;
- }
- this[_current] = dart.as(this[_queue][_table].get(this[_position]), E);
- this[_position] = dart.notNull(this[_position]) + 1 & dart.notNull(this[_queue][_table].length) - 1;
- return true;
- }
- }
- return _ListQueueIterator;
- });
- let _ListQueueIterator = _ListQueueIterator$(dart.dynamic);
- let SetMixin$ = dart.generic(function(E) {
- class SetMixin extends core.Object {
- get isEmpty() {
- return this.length === 0;
- }
- get isNotEmpty() {
- return this.length !== 0;
- }
- clear() {
- this.removeAll(this.toList());
- }
- addAll(elements) {
- for (let element of elements)
- this.add(element);
- }
- removeAll(elements) {
- for (let element of elements)
- this.remove(element);
- }
- retainAll(elements) {
- let toRemove = this.toSet();
- for (let o of elements) {
- toRemove.remove(o);
- }
- this.removeAll(toRemove);
- }
- removeWhere(test) {
- let toRemove = new List.from([]);
- for (let element of this) {
- if (test(element))
- toRemove.add(element);
- }
- this.removeAll(dart.as(toRemove, core.Iterable$(core.Object)));
- }
- retainWhere(test) {
- let toRemove = new List.from([]);
- for (let element of this) {
- if (!dart.notNull(test(element)))
- toRemove.add(element);
- }
- this.removeAll(dart.as(toRemove, core.Iterable$(core.Object)));
- }
- containsAll(other) {
- for (let o of other) {
- if (!dart.notNull(this.contains(o)))
- return false;
- }
- return true;
- }
- union(other) {
- return ((_) => {
- _.addAll(other);
- return _;
- }).bind(this)(this.toSet());
- }
- intersection(other) {
- let result = this.toSet();
- for (let element of this) {
- if (!dart.notNull(other.contains(element)))
- result.remove(element);
- }
- return result;
- }
- difference(other) {
- let result = this.toSet();
- for (let element of this) {
- if (other.contains(element))
- result.remove(element);
- }
- return result;
- }
- toList(opt$) {
- let growable = opt$.growable === void 0 ? true : opt$.growable;
- let result = growable ? ((_) => {
- _.length = this.length;
- return _;
- }).bind(this)(new core.List()) : new core.List(this.length);
- let i = 0;
- for (let element of this)
- result.set((($tmp) => i = dart.notNull($tmp) + 1, $tmp)(i), element);
- return result;
- }
- map(f) {
- return new _internal.EfficientLengthMappedIterable(this, f);
- }
- get single() {
- if (dart.notNull(this.length) > 1)
- throw _internal.IterableElementError.tooMany();
- let it = this.iterator;
- if (!dart.notNull(it.moveNext()))
- throw _internal.IterableElementError.noElement();
- let result = dart.as(it.current, E);
- return result;
- }
- toString() {
- return IterableBase.iterableToFullString(this, '{', '}');
- }
- where(f) {
- return new _internal.WhereIterable(this, f);
- }
- expand(f) {
- return new _internal.ExpandIterable(this, f);
- }
- forEach(f) {
- for (let element of this)
- f(element);
- }
- reduce(combine) {
- let iterator = this.iterator;
- if (!dart.notNull(iterator.moveNext())) {
- throw _internal.IterableElementError.noElement();
- }
- let value = iterator.current;
- while (iterator.moveNext()) {
- value = combine(value, iterator.current);
- }
- return value;
- }
- fold(initialValue, combine) {
- let value = initialValue;
- for (let element of this)
- value = combine(value, element);
- return value;
- }
- every(f) {
- for (let element of this) {
- if (!dart.notNull(f(element)))
- return false;
- }
- return true;
- }
- join(separator) {
- if (separator === void 0)
- separator = "";
- let iterator = this.iterator;
- if (!dart.notNull(iterator.moveNext()))
- return "";
- let buffer = new core.StringBuffer();
- if (dart.notNull(separator === null) || dart.notNull(dart.equals(separator, ""))) {
- do {
- buffer.write(`${iterator.current}`);
- } while (iterator.moveNext());
- } else {
- buffer.write(`${iterator.current}`);
- while (iterator.moveNext()) {
- buffer.write(separator);
- buffer.write(`${iterator.current}`);
+ this[_table].setRange(0, preSpace, dart.as(list, core.Iterable$(E)), endSpace);
+ this[_tail] = preSpace;
+ }
}
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ } else {
+ for (let element of elements)
+ this[_add](element);
}
- return buffer.toString();
}
- any(test) {
- for (let element of this) {
- if (test(element))
+ remove(object) {
+ for (let i = this[_head]; i !== this[_tail]; i = dart.notNull(i) + 1 & dart.notNull(this[_table].length) - 1) {
+ let element = this[_table].get(i);
+ if (dart.equals(element, object)) {
+ this[_remove](i);
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
return true;
+ }
}
return false;
}
- take(n) {
- return new _internal.TakeIterable(this, n);
+ [_filterWhere](test, removeMatching) {
+ let index = this[_head];
+ let modificationCount = this[_modificationCount];
+ let i = this[_head];
+ while (i !== this[_tail]) {
+ let element = this[_table].get(i);
+ let remove = core.identical(removeMatching, test(element));
+ this[_checkModification](modificationCount);
+ if (remove) {
+ i = this[_remove](i);
+ modificationCount = this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ } else {
+ i = dart.notNull(i) + 1 & dart.notNull(this[_table].length) - 1;
+ }
+ }
}
- takeWhile(test) {
- return new _internal.TakeWhileIterable(this, test);
+ removeWhere(test) {
+ this[_filterWhere](test, true);
}
- skip(n) {
- return new _internal.SkipIterable(this, n);
+ retainWhere(test) {
+ this[_filterWhere](test, false);
}
- skipWhile(test) {
- return new _internal.SkipWhileIterable(this, test);
+ clear() {
+ if (this[_head] !== this[_tail]) {
+ for (let i = this[_head]; i !== this[_tail]; i = dart.notNull(i) + 1 & dart.notNull(this[_table].length) - 1) {
+ this[_table].set(i, null);
+ }
+ this[_head] = this[_tail] = 0;
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ }
}
- get first() {
- let it = this.iterator;
- if (!dart.notNull(it.moveNext())) {
+ toString() {
+ return IterableBase.iterableToFullString(this, "{", "}");
+ }
+ addLast(element) {
+ this[_add](element);
+ }
+ addFirst(element) {
+ this[_head] = dart.notNull(this[_head]) - 1 & dart.notNull(this[_table].length) - 1;
+ this[_table].set(this[_head], element);
+ if (this[_head] === this[_tail])
+ this[_grow]();
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ }
+ removeFirst() {
+ if (this[_head] === this[_tail])
throw _internal.IterableElementError.noElement();
- }
- return dart.as(it.current, E);
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ let result = this[_table].get(this[_head]);
+ this[_table].set(this[_head], null);
+ this[_head] = dart.notNull(this[_head]) + 1 & dart.notNull(this[_table].length) - 1;
+ return result;
}
- get last() {
- let it = this.iterator;
- if (!dart.notNull(it.moveNext())) {
+ removeLast() {
+ if (this[_head] === this[_tail])
throw _internal.IterableElementError.noElement();
- }
- let result = null;
- do {
- result = dart.as(it.current, E);
- } while (it.moveNext());
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ this[_tail] = dart.notNull(this[_tail]) - 1 & dart.notNull(this[_table].length) - 1;
+ let result = this[_table].get(this[_tail]);
+ this[_table].set(this[_tail], null);
return result;
}
- firstWhere(test, opt$) {
- let orElse = opt$.orElse === void 0 ? null : opt$.orElse;
- for (let element of this) {
- if (test(element))
- return element;
+ static [_isPowerOf2](number) {
+ return (dart.notNull(number) & dart.notNull(number) - 1) === 0;
+ }
+ static [_nextPowerOf2](number) {
+ dart.assert(dart.notNull(number) > 0);
+ number = (dart.notNull(number) << 1) - 1;
+ for (;;) {
+ let nextNumber = dart.notNull(number) & dart.notNull(number) - 1;
+ if (nextNumber === 0)
+ return number;
+ number = nextNumber;
}
- if (orElse !== null)
- return orElse();
- throw _internal.IterableElementError.noElement();
}
- lastWhere(test, opt$) {
- let orElse = opt$.orElse === void 0 ? null : opt$.orElse;
- let result = null;
- let foundMatching = false;
- for (let element of this) {
- if (test(element)) {
- result = element;
- foundMatching = true;
- }
+ [_checkModification](expectedModificationCount) {
+ if (expectedModificationCount !== this[_modificationCount]) {
+ throw new core.ConcurrentModificationError(this);
}
- if (foundMatching)
- return result;
- if (orElse !== null)
- return orElse();
- throw _internal.IterableElementError.noElement();
}
- singleWhere(test) {
- let result = null;
- let foundMatching = false;
- for (let element of this) {
- if (test(element)) {
- if (foundMatching) {
- throw _internal.IterableElementError.tooMany();
- }
- result = element;
- foundMatching = true;
+ [_add](element) {
+ this[_table].set(this[_tail], element);
+ this[_tail] = dart.notNull(this[_tail]) + 1 & dart.notNull(this[_table].length) - 1;
+ if (this[_head] === this[_tail])
+ this[_grow]();
+ this[_modificationCount] = dart.notNull(this[_modificationCount]) + 1;
+ }
+ [_remove](offset) {
+ let mask = dart.notNull(this[_table].length) - 1;
+ let startDistance = dart.notNull(offset) - dart.notNull(this[_head]) & dart.notNull(mask);
+ let endDistance = dart.notNull(this[_tail]) - dart.notNull(offset) & dart.notNull(mask);
+ if (dart.notNull(startDistance) < dart.notNull(endDistance)) {
+ let i = offset;
+ while (i !== this[_head]) {
+ let prevOffset = dart.notNull(i) - 1 & dart.notNull(mask);
+ this[_table].set(i, this[_table].get(prevOffset));
+ i = prevOffset;
+ }
+ this[_table].set(this[_head], null);
+ this[_head] = dart.notNull(this[_head]) + 1 & dart.notNull(mask);
+ return dart.notNull(offset) + 1 & dart.notNull(mask);
+ } else {
+ this[_tail] = dart.notNull(this[_tail]) - 1 & dart.notNull(mask);
+ let i = offset;
+ while (i !== this[_tail]) {
+ let nextOffset = dart.notNull(i) + 1 & dart.notNull(mask);
+ this[_table].set(i, this[_table].get(nextOffset));
+ i = nextOffset;
}
+ this[_table].set(this[_tail], null);
+ return offset;
}
- if (foundMatching)
- return result;
- throw _internal.IterableElementError.noElement();
}
- elementAt(index) {
- if (!(typeof index == number))
- throw new core.ArgumentError.notNull("index");
- core.RangeError.checkNotNegative(index, "index");
- let elementIndex = 0;
- for (let element of this) {
- if (index === elementIndex)
- return element;
- elementIndex = dart.notNull(elementIndex) + 1;
+ [_grow]() {
+ let newTable = new core.List(dart.notNull(this[_table].length) * 2);
+ let split = dart.notNull(this[_table].length) - dart.notNull(this[_head]);
+ newTable.setRange(0, split, this[_table], this[_head]);
+ newTable.setRange(split, dart.notNull(split) + dart.notNull(this[_head]), this[_table], 0);
+ this[_head] = 0;
+ this[_tail] = this[_table].length;
+ this[_table] = newTable;
+ }
+ [_writeToList](target) {
+ dart.assert(dart.notNull(target.length) >= dart.notNull(this.length));
+ if (dart.notNull(this[_head]) <= dart.notNull(this[_tail])) {
+ let length = dart.notNull(this[_tail]) - dart.notNull(this[_head]);
+ target.setRange(0, length, this[_table], this[_head]);
+ return length;
+ } else {
+ let firstPartSize = dart.notNull(this[_table].length) - dart.notNull(this[_head]);
+ target.setRange(0, firstPartSize, this[_table], this[_head]);
+ target.setRange(firstPartSize, dart.notNull(firstPartSize) + dart.notNull(this[_tail]), this[_table], 0);
+ return dart.notNull(this[_tail]) + dart.notNull(firstPartSize);
}
- throw new core.RangeError.index(index, this, "index", null, elementIndex);
+ }
+ [_preGrow](newElementCount) {
+ dart.assert(dart.notNull(newElementCount) >= dart.notNull(this.length));
+ newElementCount = dart.notNull(newElementCount) >> 1;
+ let newCapacity = _nextPowerOf2(newElementCount);
+ let newTable = new core.List(newCapacity);
+ this[_tail] = this[_writeToList](newTable);
+ this[_table] = newTable;
+ this[_head] = 0;
}
}
- return SetMixin;
+ dart.defineNamedConstructor(ListQueue, 'from');
+ ListQueue._INITIAL_CAPACITY = 8;
+ return ListQueue;
});
- let SetMixin = SetMixin$(dart.dynamic);
- let SetBase$ = dart.generic(function(E) {
- class SetBase extends SetMixin$(E) {
- static setToString(set) {
- return IterableBase.iterableToFullString(set, '{', '}');
+ let ListQueue = ListQueue$(dart.dynamic);
+ let _queue = Symbol('_queue');
+ let _end = Symbol('_end');
+ let _position = Symbol('_position');
+ let _ListQueueIterator$ = dart.generic(function(E) {
+ class _ListQueueIterator extends core.Object {
+ _ListQueueIterator(queue) {
+ this[_queue] = queue;
+ this[_end] = queue[_tail];
+ this[_modificationCount] = queue[_modificationCount];
+ this[_position] = queue[_head];
+ this[_current] = null;
+ }
+ get current() {
+ return this[_current];
+ }
+ moveNext() {
+ this[_queue]._checkModification(this[_modificationCount]);
+ if (this[_position] === this[_end]) {
+ this[_current] = null;
+ return false;
+ }
+ this[_current] = dart.as(this[_queue][_table].get(this[_position]), E);
+ this[_position] = dart.notNull(this[_position]) + 1 & dart.notNull(this[_queue][_table].length) - 1;
+ return true;
}
}
- return SetBase;
+ return _ListQueueIterator;
});
- let SetBase = SetBase$(dart.dynamic);
+ let _ListQueueIterator = _ListQueueIterator$(dart.dynamic);
let _SplayTreeNode$ = dart.generic(function(K) {
class _SplayTreeNode extends core.Object {
_SplayTreeNode(key) {
@@ -4835,6 +4835,10 @@ var collection;
exports.UnmodifiableListView$ = UnmodifiableListView$;
exports.HashMap = HashMap;
exports.HashMap$ = HashMap$;
+ exports.SetBase = SetBase;
+ exports.SetBase$ = SetBase$;
+ exports.SetMixin = SetMixin;
+ exports.SetMixin$ = SetMixin$;
exports.HashSet = HashSet;
exports.HashSet$ = HashSet$;
exports.IterableMixin = IterableMixin;
@@ -4874,10 +4878,6 @@ var collection;
exports.DoubleLinkedQueue$ = DoubleLinkedQueue$;
exports.ListQueue = ListQueue;
exports.ListQueue$ = ListQueue$;
- exports.SetMixin = SetMixin;
- exports.SetMixin$ = SetMixin$;
- exports.SetBase = SetBase;
- exports.SetBase$ = SetBase$;
exports.SplayTreeMap = SplayTreeMap;
exports.SplayTreeMap$ = SplayTreeMap$;
exports.SplayTreeSet = SplayTreeSet;

Powered by Google App Engine
This is Rietveld 408576698