| OLD | NEW |
| 1 dart_library.library('collection/src/queue_list', null, /* Imports */[ | 1 dart_library.library('collection/src/queue_list', null, /* Imports */[ |
| 2 "dart/_runtime", | 2 "dart/_runtime", |
| 3 'dart/core', | 3 'dart/core', |
| 4 'dart/collection' | 4 'dart/collection' |
| 5 ], /* Lazy imports */[ | 5 ], /* Lazy imports */[ |
| 6 ], function(exports, dart, core, collection) { | 6 ], function(exports, dart, core, collection) { |
| 7 'use strict'; | 7 'use strict'; |
| 8 let dartx = dart.dartx; | 8 let dartx = dart.dartx; |
| 9 const _head = Symbol('_head'); | 9 const _head = Symbol('_head'); |
| 10 const _tail = Symbol('_tail'); | 10 const _tail = Symbol('_tail'); |
| 11 const _table = Symbol('_table'); | 11 const _table = Symbol('_table'); |
| 12 const _add = Symbol('_add'); | 12 const _add = Symbol('_add'); |
| 13 const _preGrow = Symbol('_preGrow'); | 13 const _preGrow = Symbol('_preGrow'); |
| 14 const _grow = Symbol('_grow'); | 14 const _grow = Symbol('_grow'); |
| 15 const _writeToList = Symbol('_writeToList'); | 15 const _writeToList = Symbol('_writeToList'); |
| 16 const QueueList$ = dart.generic(function(E) { | 16 const QueueList$ = dart.generic(function(E) { |
| 17 class QueueList extends dart.mixin(core.Object, collection.ListMixin$(E)) { | 17 class QueueList extends dart.mixin(core.Object, collection.ListMixin$(E)) { |
| 18 QueueList(initialCapacity) { | 18 QueueList(initialCapacity) { |
| 19 if (initialCapacity === void 0) | 19 if (initialCapacity === void 0) initialCapacity = null; |
| 20 initialCapacity = null; | |
| 21 this[_head] = 0; | 20 this[_head] = 0; |
| 22 this[_tail] = 0; | 21 this[_tail] = 0; |
| 23 this[_table] = null; | 22 this[_table] = null; |
| 24 if (initialCapacity == null || dart.notNull(initialCapacity) < dart.notN
ull(QueueList$()._INITIAL_CAPACITY)) { | 23 if (initialCapacity == null || dart.notNull(initialCapacity) < dart.notN
ull(QueueList$()._INITIAL_CAPACITY)) { |
| 25 initialCapacity = QueueList$()._INITIAL_CAPACITY; | 24 initialCapacity = QueueList$()._INITIAL_CAPACITY; |
| 26 } else if (!dart.notNull(QueueList$()._isPowerOf2(initialCapacity))) { | 25 } else if (!dart.notNull(QueueList$()._isPowerOf2(initialCapacity))) { |
| 27 initialCapacity = QueueList$()._nextPowerOf2(initialCapacity); | 26 initialCapacity = QueueList$()._nextPowerOf2(initialCapacity); |
| 28 } | 27 } |
| 29 dart.assert(QueueList$()._isPowerOf2(initialCapacity)); | 28 dart.assert(QueueList$()._isPowerOf2(initialCapacity)); |
| 30 this[_table] = core.List$(E).new(initialCapacity); | 29 this[_table] = core.List$(E).new(initialCapacity); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return collection.IterableBase.iterableToFullString(this, "{", "}"); | 78 return collection.IterableBase.iterableToFullString(this, "{", "}"); |
| 80 } | 79 } |
| 81 addLast(element) { | 80 addLast(element) { |
| 82 dart.as(element, E); | 81 dart.as(element, E); |
| 83 this[_add](element); | 82 this[_add](element); |
| 84 } | 83 } |
| 85 addFirst(element) { | 84 addFirst(element) { |
| 86 dart.as(element, E); | 85 dart.as(element, E); |
| 87 this[_head] = dart.notNull(this[_head]) - 1 & dart.notNull(this[_table][
dartx.length]) - 1; | 86 this[_head] = dart.notNull(this[_head]) - 1 & dart.notNull(this[_table][
dartx.length]) - 1; |
| 88 this[_table][dartx.set](this[_head], element); | 87 this[_table][dartx.set](this[_head], element); |
| 89 if (this[_head] == this[_tail]) | 88 if (this[_head] == this[_tail]) this[_grow](); |
| 90 this[_grow](); | |
| 91 } | 89 } |
| 92 removeFirst() { | 90 removeFirst() { |
| 93 if (this[_head] == this[_tail]) | 91 if (this[_head] == this[_tail]) dart.throw(new core.StateError("No eleme
nt")); |
| 94 dart.throw(new core.StateError("No element")); | |
| 95 let result = this[_table][dartx.get](this[_head]); | 92 let result = this[_table][dartx.get](this[_head]); |
| 96 this[_table][dartx.set](this[_head], null); | 93 this[_table][dartx.set](this[_head], null); |
| 97 this[_head] = dart.notNull(this[_head]) + 1 & dart.notNull(this[_table][
dartx.length]) - 1; | 94 this[_head] = dart.notNull(this[_head]) + 1 & dart.notNull(this[_table][
dartx.length]) - 1; |
| 98 return result; | 95 return result; |
| 99 } | 96 } |
| 100 removeLast() { | 97 removeLast() { |
| 101 if (this[_head] == this[_tail]) | 98 if (this[_head] == this[_tail]) dart.throw(new core.StateError("No eleme
nt")); |
| 102 dart.throw(new core.StateError("No element")); | |
| 103 this[_tail] = dart.notNull(this[_tail]) - 1 & dart.notNull(this[_table][
dartx.length]) - 1; | 99 this[_tail] = dart.notNull(this[_tail]) - 1 & dart.notNull(this[_table][
dartx.length]) - 1; |
| 104 let result = this[_table][dartx.get](this[_tail]); | 100 let result = this[_table][dartx.get](this[_tail]); |
| 105 this[_table][dartx.set](this[_tail], null); | 101 this[_table][dartx.set](this[_tail], null); |
| 106 return result; | 102 return result; |
| 107 } | 103 } |
| 108 get length() { | 104 get length() { |
| 109 return dart.notNull(this[_tail]) - dart.notNull(this[_head]) & dart.notN
ull(this[_table][dartx.length]) - 1; | 105 return dart.notNull(this[_tail]) - dart.notNull(this[_head]) & dart.notN
ull(this[_table][dartx.length]) - 1; |
| 110 } | 106 } |
| 111 set length(value) { | 107 set length(value) { |
| 112 if (dart.notNull(value) < 0) | 108 if (dart.notNull(value) < 0) dart.throw(new core.RangeError(`Length ${va
lue} may not be negative.`)); |
| 113 dart.throw(new core.RangeError(`Length ${value} may not be negative.`)
); | |
| 114 let delta = dart.notNull(value) - dart.notNull(this.length); | 109 let delta = dart.notNull(value) - dart.notNull(this.length); |
| 115 if (dart.notNull(delta) >= 0) { | 110 if (dart.notNull(delta) >= 0) { |
| 116 if (dart.notNull(this[_table][dartx.length]) <= dart.notNull(value)) { | 111 if (dart.notNull(this[_table][dartx.length]) <= dart.notNull(value)) { |
| 117 this[_preGrow](value); | 112 this[_preGrow](value); |
| 118 } | 113 } |
| 119 this[_tail] = dart.notNull(this[_tail]) + dart.notNull(delta) & dart.n
otNull(this[_table][dartx.length]) - 1; | 114 this[_tail] = dart.notNull(this[_tail]) + dart.notNull(delta) & dart.n
otNull(this[_table][dartx.length]) - 1; |
| 120 return; | 115 return; |
| 121 } | 116 } |
| 122 let newTail = dart.notNull(this[_tail]) + dart.notNull(delta); | 117 let newTail = dart.notNull(this[_tail]) + dart.notNull(delta); |
| 123 if (dart.notNull(newTail) >= 0) { | 118 if (dart.notNull(newTail) >= 0) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 144 return value; | 139 return value; |
| 145 } | 140 } |
| 146 static _isPowerOf2(number) { | 141 static _isPowerOf2(number) { |
| 147 return (dart.notNull(number) & dart.notNull(number) - 1) == 0; | 142 return (dart.notNull(number) & dart.notNull(number) - 1) == 0; |
| 148 } | 143 } |
| 149 static _nextPowerOf2(number) { | 144 static _nextPowerOf2(number) { |
| 150 dart.assert(dart.notNull(number) > 0); | 145 dart.assert(dart.notNull(number) > 0); |
| 151 number = (dart.notNull(number) << 1) - 1; | 146 number = (dart.notNull(number) << 1) - 1; |
| 152 for (;;) { | 147 for (;;) { |
| 153 let nextNumber = dart.notNull(number) & dart.notNull(number) - 1; | 148 let nextNumber = dart.notNull(number) & dart.notNull(number) - 1; |
| 154 if (nextNumber == 0) | 149 if (nextNumber == 0) return number; |
| 155 return number; | |
| 156 number = nextNumber; | 150 number = nextNumber; |
| 157 } | 151 } |
| 158 } | 152 } |
| 159 [_add](element) { | 153 [_add](element) { |
| 160 dart.as(element, E); | 154 dart.as(element, E); |
| 161 this[_table][dartx.set](this[_tail], element); | 155 this[_table][dartx.set](this[_tail], element); |
| 162 this[_tail] = dart.notNull(this[_tail]) + 1 & dart.notNull(this[_table][
dartx.length]) - 1; | 156 this[_tail] = dart.notNull(this[_tail]) + 1 & dart.notNull(this[_table][
dartx.length]) - 1; |
| 163 if (this[_head] == this[_tail]) | 157 if (this[_head] == this[_tail]) this[_grow](); |
| 164 this[_grow](); | |
| 165 } | 158 } |
| 166 [_grow]() { | 159 [_grow]() { |
| 167 let newTable = core.List$(E).new(dart.notNull(this[_table][dartx.length]
) * 2); | 160 let newTable = core.List$(E).new(dart.notNull(this[_table][dartx.length]
) * 2); |
| 168 let split = dart.notNull(this[_table][dartx.length]) - dart.notNull(this
[_head]); | 161 let split = dart.notNull(this[_table][dartx.length]) - dart.notNull(this
[_head]); |
| 169 newTable[dartx.setRange](0, split, this[_table], this[_head]); | 162 newTable[dartx.setRange](0, split, this[_table], this[_head]); |
| 170 newTable[dartx.setRange](split, dart.notNull(split) + dart.notNull(this[
_head]), this[_table], 0); | 163 newTable[dartx.setRange](split, dart.notNull(split) + dart.notNull(this[
_head]), this[_table], 0); |
| 171 this[_head] = 0; | 164 this[_head] = 0; |
| 172 this[_tail] = this[_table][dartx.length]; | 165 this[_tail] = this[_table][dartx.length]; |
| 173 this[_table] = newTable; | 166 this[_table] = newTable; |
| 174 } | 167 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 'length' | 226 'length' |
| 234 ]); | 227 ]); |
| 235 return QueueList; | 228 return QueueList; |
| 236 }); | 229 }); |
| 237 let QueueList = QueueList$(); | 230 let QueueList = QueueList$(); |
| 238 QueueList._INITIAL_CAPACITY = 8; | 231 QueueList._INITIAL_CAPACITY = 8; |
| 239 // Exports: | 232 // Exports: |
| 240 exports.QueueList$ = QueueList$; | 233 exports.QueueList$ = QueueList$; |
| 241 exports.QueueList = QueueList; | 234 exports.QueueList = QueueList; |
| 242 }); | 235 }); |
| OLD | NEW |