| OLD | NEW |
| (Empty) |
| 1 var collection; | |
| 2 (function(exports) { | |
| 3 'use strict'; | |
| 4 let _HashMap$ = dart.generic(function(K, V) { | |
| 5 class _HashMap extends dart.Object { | |
| 6 _HashMap() { | |
| 7 this._length = 0; | |
| 8 this._strings = null; | |
| 9 this._nums = null; | |
| 10 this._rest = null; | |
| 11 this._keys = null; | |
| 12 } | |
| 13 get length() { | |
| 14 return this._length; | |
| 15 } | |
| 16 get isEmpty() { | |
| 17 return this._length === 0; | |
| 18 } | |
| 19 get isNotEmpty() { | |
| 20 return !dart.notNull(this.isEmpty); | |
| 21 } | |
| 22 get keys() { | |
| 23 return new HashMapKeyIterable(this); | |
| 24 } | |
| 25 get values() { | |
| 26 return new _internal.MappedIterable(this.keys, ((each) => this.get(each)
).bind(this)); | |
| 27 } | |
| 28 containsKey(key) { | |
| 29 if (_isStringKey(key)) { | |
| 30 let strings = this._strings; | |
| 31 return strings === null ? false : _hasTableEntry(strings, key); | |
| 32 } else if (_isNumericKey(key)) { | |
| 33 let nums = this._nums; | |
| 34 return nums === null ? false : _hasTableEntry(nums, key); | |
| 35 } else { | |
| 36 return this._containsKey(key); | |
| 37 } | |
| 38 } | |
| 39 _containsKey(key) { | |
| 40 let rest = this._rest; | |
| 41 if (rest === null) | |
| 42 return false; | |
| 43 let bucket = this._getBucket(rest, key); | |
| 44 return this._findBucketIndex(bucket, key) >= 0; | |
| 45 } | |
| 46 containsValue(value) { | |
| 47 return this._computeKeys().any(((each) => dart.equals(this.get(each), va
lue)).bind(this)); | |
| 48 } | |
| 49 addAll(other) { | |
| 50 other.forEach(((key, value) => { | |
| 51 this.set(key, value); | |
| 52 }).bind(this)); | |
| 53 } | |
| 54 get(key) { | |
| 55 if (_isStringKey(key)) { | |
| 56 let strings = this._strings; | |
| 57 return dart.as(strings === null ? null : _getTableEntry(strings, key),
V); | |
| 58 } else if (_isNumericKey(key)) { | |
| 59 let nums = this._nums; | |
| 60 return dart.as(nums === null ? null : _getTableEntry(nums, key), V); | |
| 61 } else { | |
| 62 return this._get(key); | |
| 63 } | |
| 64 } | |
| 65 _get(key) { | |
| 66 let rest = this._rest; | |
| 67 if (rest === null) | |
| 68 return dart.as(null, V); | |
| 69 let bucket = this._getBucket(rest, key); | |
| 70 let index = this._findBucketIndex(bucket, key); | |
| 71 return dart.as(index < 0 ? null : bucket[index + 1], V); | |
| 72 } | |
| 73 set(key, value) { | |
| 74 if (_isStringKey(key)) { | |
| 75 let strings = this._strings; | |
| 76 if (strings === null) | |
| 77 this._strings = strings = _newHashTable(); | |
| 78 this._addHashTableEntry(strings, key, value); | |
| 79 } else if (_isNumericKey(key)) { | |
| 80 let nums = this._nums; | |
| 81 if (nums === null) | |
| 82 this._nums = nums = _newHashTable(); | |
| 83 this._addHashTableEntry(nums, key, value); | |
| 84 } else { | |
| 85 this._set(key, value); | |
| 86 } | |
| 87 } | |
| 88 _set(key, value) { | |
| 89 let rest = this._rest; | |
| 90 if (rest === null) | |
| 91 this._rest = rest = _newHashTable(); | |
| 92 let hash = this._computeHashCode(key); | |
| 93 let bucket = rest[hash]; | |
| 94 if (bucket === null) { | |
| 95 _setTableEntry(rest, hash, [key, value]); | |
| 96 this._length++; | |
| 97 this._keys = null; | |
| 98 } else { | |
| 99 let index = this._findBucketIndex(bucket, key); | |
| 100 if (index >= 0) { | |
| 101 bucket[index + 1] = value; | |
| 102 } else { | |
| 103 bucket.push(key, value); | |
| 104 this._length++; | |
| 105 this._keys = null; | |
| 106 } | |
| 107 } | |
| 108 } | |
| 109 putIfAbsent(key, ifAbsent) { | |
| 110 if (this.containsKey(key)) | |
| 111 return this.get(key); | |
| 112 let value = ifAbsent(); | |
| 113 this.set(key, value); | |
| 114 return value; | |
| 115 } | |
| 116 remove(key) { | |
| 117 if (_isStringKey(key)) { | |
| 118 return this._removeHashTableEntry(this._strings, key); | |
| 119 } else if (_isNumericKey(key)) { | |
| 120 return this._removeHashTableEntry(this._nums, key); | |
| 121 } else { | |
| 122 return this._remove(key); | |
| 123 } | |
| 124 } | |
| 125 _remove(key) { | |
| 126 let rest = this._rest; | |
| 127 if (rest === null) | |
| 128 return dart.as(null, V); | |
| 129 let bucket = this._getBucket(rest, key); | |
| 130 let index = this._findBucketIndex(bucket, key); | |
| 131 if (index < 0) | |
| 132 return dart.as(null, V); | |
| 133 this._length--; | |
| 134 this._keys = null; | |
| 135 return dart.as(bucket.splice(index, 2)[1], V); | |
| 136 } | |
| 137 clear() { | |
| 138 if (this._length > 0) { | |
| 139 this._strings = this._nums = this._rest = this._keys = null; | |
| 140 this._length = 0; | |
| 141 } | |
| 142 } | |
| 143 forEach(action) { | |
| 144 let keys = this._computeKeys(); | |
| 145 for (let i = 0, length = keys.length; i < length; i++) { | |
| 146 let key = keys[i]; | |
| 147 action(dart.as(key, K), this.get(key)); | |
| 148 if (keys !== this._keys) { | |
| 149 throw new core.ConcurrentModificationError(this); | |
| 150 } | |
| 151 } | |
| 152 } | |
| 153 _computeKeys() { | |
| 154 if (this._keys !== null) | |
| 155 return this._keys; | |
| 156 let result = new core.List(this._length); | |
| 157 let index = 0; | |
| 158 let strings = this._strings; | |
| 159 if (strings !== null) { | |
| 160 let names = Object.getOwnPropertyNames(strings); | |
| 161 let entries = names.length; | |
| 162 for (let i = 0; i < entries; i++) { | |
| 163 let key = names[i]; | |
| 164 result[index] = key; | |
| 165 index++; | |
| 166 } | |
| 167 } | |
| 168 let nums = this._nums; | |
| 169 if (nums !== null) { | |
| 170 let names = Object.getOwnPropertyNames(nums); | |
| 171 let entries = names.length; | |
| 172 for (let i = 0; i < entries; i++) { | |
| 173 let key = +names[i]; | |
| 174 result[index] = key; | |
| 175 index++; | |
| 176 } | |
| 177 } | |
| 178 let rest = this._rest; | |
| 179 if (rest !== null) { | |
| 180 let names = Object.getOwnPropertyNames(rest); | |
| 181 let entries = names.length; | |
| 182 for (let i = 0; i < entries; i++) { | |
| 183 let key = names[i]; | |
| 184 let bucket = rest[key]; | |
| 185 let length = bucket.length; | |
| 186 for (let i = 0; i < length; i = 2) { | |
| 187 let key = bucket[i]; | |
| 188 result[index] = key; | |
| 189 index++; | |
| 190 } | |
| 191 } | |
| 192 } | |
| 193 dart.assert(index === this._length); | |
| 194 return this._keys = result; | |
| 195 } | |
| 196 _addHashTableEntry(table, key, value) { | |
| 197 if (!dart.notNull(_hasTableEntry(table, key))) { | |
| 198 this._length++; | |
| 199 this._keys = null; | |
| 200 } | |
| 201 _setTableEntry(table, key, value); | |
| 202 } | |
| 203 _removeHashTableEntry(table, key) { | |
| 204 if (dart.notNull(table !== null) && dart.notNull(_hasTableEntry(table, k
ey))) { | |
| 205 let value = dart.as(_getTableEntry(table, key), V); | |
| 206 _deleteTableEntry(table, key); | |
| 207 this._length--; | |
| 208 this._keys = null; | |
| 209 return value; | |
| 210 } else { | |
| 211 return dart.as(null, V); | |
| 212 } | |
| 213 } | |
| 214 static _isStringKey(key) { | |
| 215 return dart.notNull(typeof key == string) && dart.notNull(!dart.equals(k
ey, '__proto__')); | |
| 216 } | |
| 217 static _isNumericKey(key) { | |
| 218 return dart.notNull(dart.is(key, core.num)) && dart.notNull((key & 0x3ff
ffff) === key); | |
| 219 } | |
| 220 _computeHashCode(key) { | |
| 221 return dart.dload(key, 'hashCode') & 0x3ffffff; | |
| 222 } | |
| 223 static _hasTableEntry(table, key) { | |
| 224 let entry = table[key]; | |
| 225 return entry !== null; | |
| 226 } | |
| 227 static _getTableEntry(table, key) { | |
| 228 let entry = table[key]; | |
| 229 return entry === table ? null : entry; | |
| 230 } | |
| 231 static _setTableEntry(table, key, value) { | |
| 232 if (value === null) { | |
| 233 table[key] = table; | |
| 234 } else { | |
| 235 table[key] = value; | |
| 236 } | |
| 237 } | |
| 238 static _deleteTableEntry(table, key) { | |
| 239 delete table[key]; | |
| 240 } | |
| 241 _getBucket(table, key) { | |
| 242 let hash = this._computeHashCode(key); | |
| 243 return dart.as(table[hash], core.List); | |
| 244 } | |
| 245 _findBucketIndex(bucket, key) { | |
| 246 if (bucket === null) | |
| 247 return -1; | |
| 248 let length = bucket.length; | |
| 249 for (let i = 0; i < length; i = 2) { | |
| 250 if (dart.equals(bucket[i], key)) | |
| 251 return i; | |
| 252 } | |
| 253 return -1; | |
| 254 } | |
| 255 static _newHashTable() { | |
| 256 let table = Object.create(null); | |
| 257 let temporaryKey = '<non-identifier-key>'; | |
| 258 _setTableEntry(table, temporaryKey, table); | |
| 259 _deleteTableEntry(table, temporaryKey); | |
| 260 return table; | |
| 261 } | |
| 262 } | |
| 263 return _HashMap; | |
| 264 }); | |
| 265 let _HashMap = _HashMap$(dynamic, dynamic); | |
| 266 let _IdentityHashMap$ = dart.generic(function(K, V) { | |
| 267 class _IdentityHashMap extends _HashMap$(K, V) { | |
| 268 _computeHashCode(key) { | |
| 269 return core.identityHashCode(key) & 0x3ffffff; | |
| 270 } | |
| 271 _findBucketIndex(bucket, key) { | |
| 272 if (bucket === null) | |
| 273 return -1; | |
| 274 let length = bucket.length; | |
| 275 for (let i = 0; i < length; i = 2) { | |
| 276 if (core.identical(bucket[i], key)) | |
| 277 return i; | |
| 278 } | |
| 279 return -1; | |
| 280 } | |
| 281 } | |
| 282 return _IdentityHashMap; | |
| 283 }); | |
| 284 let _IdentityHashMap = _IdentityHashMap$(dynamic, dynamic); | |
| 285 let _CustomHashMap$ = dart.generic(function(K, V) { | |
| 286 class _CustomHashMap extends _HashMap$(K, V) { | |
| 287 _CustomHashMap(_equals, _hashCode, validKey) { | |
| 288 this._equals = _equals; | |
| 289 this._hashCode = _hashCode; | |
| 290 this._validKey = dart.as(validKey !== null ? validKey : (v) => dart.is(v
, K), _Predicate); | |
| 291 super._HashMap(); | |
| 292 } | |
| 293 get(key) { | |
| 294 if (!dart.notNull(this._validKey(key))) | |
| 295 return dart.as(null, V); | |
| 296 return super._get(key); | |
| 297 } | |
| 298 set(key, value) { | |
| 299 super._set(key, value); | |
| 300 } | |
| 301 containsKey(key) { | |
| 302 if (!dart.notNull(this._validKey(key))) | |
| 303 return false; | |
| 304 return super._containsKey(key); | |
| 305 } | |
| 306 remove(key) { | |
| 307 if (!dart.notNull(this._validKey(key))) | |
| 308 return dart.as(null, V); | |
| 309 return super._remove(key); | |
| 310 } | |
| 311 _computeHashCode(key) { | |
| 312 return this._hashCode(dart.as(key, K)) & 0x3ffffff; | |
| 313 } | |
| 314 _findBucketIndex(bucket, key) { | |
| 315 if (bucket === null) | |
| 316 return -1; | |
| 317 let length = bucket.length; | |
| 318 for (let i = 0; i < length; i = 2) { | |
| 319 if (this._equals(dart.as(bucket[i], K), dart.as(key, K))) | |
| 320 return i; | |
| 321 } | |
| 322 return -1; | |
| 323 } | |
| 324 toString() { | |
| 325 return Maps.mapToString(this); | |
| 326 } | |
| 327 } | |
| 328 return _CustomHashMap; | |
| 329 }); | |
| 330 let _CustomHashMap = _CustomHashMap$(dynamic, dynamic); | |
| 331 let HashMapKeyIterable$ = dart.generic(function(E) { | |
| 332 class HashMapKeyIterable extends IterableBase$(E) { | |
| 333 HashMapKeyIterable(_map) { | |
| 334 this._map = _map; | |
| 335 super.IterableBase(); | |
| 336 } | |
| 337 get length() { | |
| 338 return dart.as(dart.dload(this._map, '_length'), core.int); | |
| 339 } | |
| 340 get isEmpty() { | |
| 341 return dart.equals(dart.dload(this._map, '_length'), 0); | |
| 342 } | |
| 343 get iterator() { | |
| 344 return new HashMapKeyIterator(this._map, dart.as(dart.dinvoke(this._map,
'_computeKeys'), core.List)); | |
| 345 } | |
| 346 contains(element) { | |
| 347 return dart.as(dart.dinvoke(this._map, 'containsKey', element), core.boo
l); | |
| 348 } | |
| 349 forEach(f) { | |
| 350 let keys = dart.as(dart.dinvoke(this._map, '_computeKeys'), core.List); | |
| 351 for (let i = 0, length = keys.length; i < length; i++) { | |
| 352 f(dart.as(keys[i], E)); | |
| 353 if (keys !== dart.dload(this._map, '_keys')) { | |
| 354 throw new core.ConcurrentModificationError(this._map); | |
| 355 } | |
| 356 } | |
| 357 } | |
| 358 } | |
| 359 return HashMapKeyIterable; | |
| 360 }); | |
| 361 let HashMapKeyIterable = HashMapKeyIterable$(dynamic); | |
| 362 let HashMapKeyIterator$ = dart.generic(function(E) { | |
| 363 class HashMapKeyIterator extends dart.Object { | |
| 364 HashMapKeyIterator(_map, _keys) { | |
| 365 this._map = _map; | |
| 366 this._keys = _keys; | |
| 367 this._offset = 0; | |
| 368 this._current = dart.as(null, E); | |
| 369 } | |
| 370 get current() { | |
| 371 return this._current; | |
| 372 } | |
| 373 moveNext() { | |
| 374 let keys = this._keys; | |
| 375 let offset = this._offset; | |
| 376 if (keys !== dart.dload(this._map, '_keys')) { | |
| 377 throw new core.ConcurrentModificationError(this._map); | |
| 378 } else if (offset >= keys.length) { | |
| 379 this._current = dart.as(null, E); | |
| 380 return false; | |
| 381 } else { | |
| 382 this._current = dart.as(keys[offset], E); | |
| 383 this._offset = offset + 1; | |
| 384 return true; | |
| 385 } | |
| 386 } | |
| 387 } | |
| 388 return HashMapKeyIterator; | |
| 389 }); | |
| 390 let HashMapKeyIterator = HashMapKeyIterator$(dynamic); | |
| 391 let _LinkedHashMap$ = dart.generic(function(K, V) { | |
| 392 class _LinkedHashMap extends dart.Object { | |
| 393 _LinkedHashMap() { | |
| 394 this._length = 0; | |
| 395 this._strings = null; | |
| 396 this._nums = null; | |
| 397 this._rest = null; | |
| 398 this._first = null; | |
| 399 this._last = null; | |
| 400 this._modifications = 0; | |
| 401 } | |
| 402 get length() { | |
| 403 return this._length; | |
| 404 } | |
| 405 get isEmpty() { | |
| 406 return this._length === 0; | |
| 407 } | |
| 408 get isNotEmpty() { | |
| 409 return !dart.notNull(this.isEmpty); | |
| 410 } | |
| 411 get keys() { | |
| 412 return new LinkedHashMapKeyIterable(this); | |
| 413 } | |
| 414 get values() { | |
| 415 return new _internal.MappedIterable(this.keys, ((each) => this.get(each)
).bind(this)); | |
| 416 } | |
| 417 containsKey(key) { | |
| 418 if (_isStringKey(key)) { | |
| 419 let strings = this._strings; | |
| 420 if (strings === null) | |
| 421 return false; | |
| 422 let cell = dart.as(_getTableEntry(strings, key), LinkedHashMapCell); | |
| 423 return cell !== null; | |
| 424 } else if (_isNumericKey(key)) { | |
| 425 let nums = this._nums; | |
| 426 if (nums === null) | |
| 427 return false; | |
| 428 let cell = dart.as(_getTableEntry(nums, key), LinkedHashMapCell); | |
| 429 return cell !== null; | |
| 430 } else { | |
| 431 return this._containsKey(key); | |
| 432 } | |
| 433 } | |
| 434 _containsKey(key) { | |
| 435 let rest = this._rest; | |
| 436 if (rest === null) | |
| 437 return false; | |
| 438 let bucket = this._getBucket(rest, key); | |
| 439 return this._findBucketIndex(bucket, key) >= 0; | |
| 440 } | |
| 441 containsValue(value) { | |
| 442 return this.keys.any(((each) => dart.equals(this.get(each), value)).bind
(this)); | |
| 443 } | |
| 444 addAll(other) { | |
| 445 other.forEach(((key, value) => { | |
| 446 this.set(key, value); | |
| 447 }).bind(this)); | |
| 448 } | |
| 449 get(key) { | |
| 450 if (_isStringKey(key)) { | |
| 451 let strings = this._strings; | |
| 452 if (strings === null) | |
| 453 return dart.as(null, V); | |
| 454 let cell = dart.as(_getTableEntry(strings, key), LinkedHashMapCell); | |
| 455 return dart.as(cell === null ? null : cell._value, V); | |
| 456 } else if (_isNumericKey(key)) { | |
| 457 let nums = this._nums; | |
| 458 if (nums === null) | |
| 459 return dart.as(null, V); | |
| 460 let cell = dart.as(_getTableEntry(nums, key), LinkedHashMapCell); | |
| 461 return dart.as(cell === null ? null : cell._value, V); | |
| 462 } else { | |
| 463 return this._get(key); | |
| 464 } | |
| 465 } | |
| 466 _get(key) { | |
| 467 let rest = this._rest; | |
| 468 if (rest === null) | |
| 469 return dart.as(null, V); | |
| 470 let bucket = this._getBucket(rest, key); | |
| 471 let index = this._findBucketIndex(bucket, key); | |
| 472 if (index < 0) | |
| 473 return dart.as(null, V); | |
| 474 let cell = dart.as(bucket[index], LinkedHashMapCell); | |
| 475 return dart.as(cell._value, V); | |
| 476 } | |
| 477 set(key, value) { | |
| 478 if (_isStringKey(key)) { | |
| 479 let strings = this._strings; | |
| 480 if (strings === null) | |
| 481 this._strings = strings = _newHashTable(); | |
| 482 this._addHashTableEntry(strings, key, value); | |
| 483 } else if (_isNumericKey(key)) { | |
| 484 let nums = this._nums; | |
| 485 if (nums === null) | |
| 486 this._nums = nums = _newHashTable(); | |
| 487 this._addHashTableEntry(nums, key, value); | |
| 488 } else { | |
| 489 this._set(key, value); | |
| 490 } | |
| 491 } | |
| 492 _set(key, value) { | |
| 493 let rest = this._rest; | |
| 494 if (rest === null) | |
| 495 this._rest = rest = _newHashTable(); | |
| 496 let hash = this._computeHashCode(key); | |
| 497 let bucket = rest[hash]; | |
| 498 if (bucket === null) { | |
| 499 let cell = this._newLinkedCell(key, value); | |
| 500 _setTableEntry(rest, hash, [cell]); | |
| 501 } else { | |
| 502 let index = this._findBucketIndex(bucket, key); | |
| 503 if (index >= 0) { | |
| 504 let cell = dart.as(bucket[index], LinkedHashMapCell); | |
| 505 cell._value = value; | |
| 506 } else { | |
| 507 let cell = this._newLinkedCell(key, value); | |
| 508 bucket.push(cell); | |
| 509 } | |
| 510 } | |
| 511 } | |
| 512 putIfAbsent(key, ifAbsent) { | |
| 513 if (this.containsKey(key)) | |
| 514 return this.get(key); | |
| 515 let value = ifAbsent(); | |
| 516 this.set(key, value); | |
| 517 return value; | |
| 518 } | |
| 519 remove(key) { | |
| 520 if (_isStringKey(key)) { | |
| 521 return this._removeHashTableEntry(this._strings, key); | |
| 522 } else if (_isNumericKey(key)) { | |
| 523 return this._removeHashTableEntry(this._nums, key); | |
| 524 } else { | |
| 525 return this._remove(key); | |
| 526 } | |
| 527 } | |
| 528 _remove(key) { | |
| 529 let rest = this._rest; | |
| 530 if (rest === null) | |
| 531 return dart.as(null, V); | |
| 532 let bucket = this._getBucket(rest, key); | |
| 533 let index = this._findBucketIndex(bucket, key); | |
| 534 if (index < 0) | |
| 535 return dart.as(null, V); | |
| 536 let cell = dart.as(bucket.splice(index, 1)[0], LinkedHashMapCell); | |
| 537 this._unlinkCell(cell); | |
| 538 return dart.as(cell._value, V); | |
| 539 } | |
| 540 clear() { | |
| 541 if (this._length > 0) { | |
| 542 this._strings = this._nums = this._rest = this._first = this._last = n
ull; | |
| 543 this._length = 0; | |
| 544 this._modified(); | |
| 545 } | |
| 546 } | |
| 547 forEach(action) { | |
| 548 let cell = this._first; | |
| 549 let modifications = this._modifications; | |
| 550 while (cell !== null) { | |
| 551 action(dart.as(cell._key, K), dart.as(cell._value, V)); | |
| 552 if (modifications !== this._modifications) { | |
| 553 throw new core.ConcurrentModificationError(this); | |
| 554 } | |
| 555 cell = cell._next; | |
| 556 } | |
| 557 } | |
| 558 _addHashTableEntry(table, key, value) { | |
| 559 let cell = dart.as(_getTableEntry(table, key), LinkedHashMapCell); | |
| 560 if (cell === null) { | |
| 561 _setTableEntry(table, key, this._newLinkedCell(key, value)); | |
| 562 } else { | |
| 563 cell._value = value; | |
| 564 } | |
| 565 } | |
| 566 _removeHashTableEntry(table, key) { | |
| 567 if (table === null) | |
| 568 return dart.as(null, V); | |
| 569 let cell = dart.as(_getTableEntry(table, key), LinkedHashMapCell); | |
| 570 if (cell === null) | |
| 571 return dart.as(null, V); | |
| 572 this._unlinkCell(cell); | |
| 573 _deleteTableEntry(table, key); | |
| 574 return dart.as(cell._value, V); | |
| 575 } | |
| 576 _modified() { | |
| 577 this._modifications = this._modifications + 1 & 67108863; | |
| 578 } | |
| 579 _newLinkedCell(key, value) { | |
| 580 let cell = new LinkedHashMapCell(key, value); | |
| 581 if (this._first === null) { | |
| 582 this._first = this._last = cell; | |
| 583 } else { | |
| 584 let last = this._last; | |
| 585 cell._previous = last; | |
| 586 this._last = last._next = cell; | |
| 587 } | |
| 588 this._length++; | |
| 589 this._modified(); | |
| 590 return cell; | |
| 591 } | |
| 592 _unlinkCell(cell) { | |
| 593 let previous = cell._previous; | |
| 594 let next = cell._next; | |
| 595 if (previous === null) { | |
| 596 dart.assert(dart.equals(cell, this._first)); | |
| 597 this._first = next; | |
| 598 } else { | |
| 599 previous._next = next; | |
| 600 } | |
| 601 if (next === null) { | |
| 602 dart.assert(dart.equals(cell, this._last)); | |
| 603 this._last = previous; | |
| 604 } else { | |
| 605 next._previous = previous; | |
| 606 } | |
| 607 this._length--; | |
| 608 this._modified(); | |
| 609 } | |
| 610 static _isStringKey(key) { | |
| 611 return dart.notNull(typeof key == string) && dart.notNull(!dart.equals(k
ey, '__proto__')); | |
| 612 } | |
| 613 static _isNumericKey(key) { | |
| 614 return dart.notNull(dart.is(key, core.num)) && dart.notNull((key & 0x3ff
ffff) === key); | |
| 615 } | |
| 616 _computeHashCode(key) { | |
| 617 return dart.dload(key, 'hashCode') & 0x3ffffff; | |
| 618 } | |
| 619 static _getTableEntry(table, key) { | |
| 620 return table[key]; | |
| 621 } | |
| 622 static _setTableEntry(table, key, value) { | |
| 623 dart.assert(value !== null); | |
| 624 table[key] = value; | |
| 625 } | |
| 626 static _deleteTableEntry(table, key) { | |
| 627 delete table[key]; | |
| 628 } | |
| 629 _getBucket(table, key) { | |
| 630 let hash = this._computeHashCode(key); | |
| 631 return dart.as(table[hash], core.List); | |
| 632 } | |
| 633 _findBucketIndex(bucket, key) { | |
| 634 if (bucket === null) | |
| 635 return -1; | |
| 636 let length = bucket.length; | |
| 637 for (let i = 0; i < length; i++) { | |
| 638 let cell = dart.as(bucket[i], LinkedHashMapCell); | |
| 639 if (dart.equals(cell._key, key)) | |
| 640 return i; | |
| 641 } | |
| 642 return -1; | |
| 643 } | |
| 644 static _newHashTable() { | |
| 645 let table = Object.create(null); | |
| 646 let temporaryKey = '<non-identifier-key>'; | |
| 647 _setTableEntry(table, temporaryKey, table); | |
| 648 _deleteTableEntry(table, temporaryKey); | |
| 649 return table; | |
| 650 } | |
| 651 toString() { | |
| 652 return Maps.mapToString(this); | |
| 653 } | |
| 654 } | |
| 655 return _LinkedHashMap; | |
| 656 }); | |
| 657 let _LinkedHashMap = _LinkedHashMap$(dynamic, dynamic); | |
| 658 let _LinkedIdentityHashMap$ = dart.generic(function(K, V) { | |
| 659 class _LinkedIdentityHashMap extends _LinkedHashMap$(K, V) { | |
| 660 _computeHashCode(key) { | |
| 661 return core.identityHashCode(key) & 0x3ffffff; | |
| 662 } | |
| 663 _findBucketIndex(bucket, key) { | |
| 664 if (bucket === null) | |
| 665 return -1; | |
| 666 let length = bucket.length; | |
| 667 for (let i = 0; i < length; i++) { | |
| 668 let cell = dart.as(bucket[i], LinkedHashMapCell); | |
| 669 if (core.identical(cell._key, key)) | |
| 670 return i; | |
| 671 } | |
| 672 return -1; | |
| 673 } | |
| 674 } | |
| 675 return _LinkedIdentityHashMap; | |
| 676 }); | |
| 677 let _LinkedIdentityHashMap = _LinkedIdentityHashMap$(dynamic, dynamic); | |
| 678 let _LinkedCustomHashMap$ = dart.generic(function(K, V) { | |
| 679 class _LinkedCustomHashMap extends _LinkedHashMap$(K, V) { | |
| 680 _LinkedCustomHashMap(_equals, _hashCode, validKey) { | |
| 681 this._equals = _equals; | |
| 682 this._hashCode = _hashCode; | |
| 683 this._validKey = dart.as(validKey !== null ? validKey : (v) => dart.is(v
, K), _Predicate); | |
| 684 super._LinkedHashMap(); | |
| 685 } | |
| 686 get(key) { | |
| 687 if (!dart.notNull(this._validKey(key))) | |
| 688 return dart.as(null, V); | |
| 689 return super._get(key); | |
| 690 } | |
| 691 set(key, value) { | |
| 692 super._set(key, value); | |
| 693 } | |
| 694 containsKey(key) { | |
| 695 if (!dart.notNull(this._validKey(key))) | |
| 696 return false; | |
| 697 return super._containsKey(key); | |
| 698 } | |
| 699 remove(key) { | |
| 700 if (!dart.notNull(this._validKey(key))) | |
| 701 return dart.as(null, V); | |
| 702 return super._remove(key); | |
| 703 } | |
| 704 _computeHashCode(key) { | |
| 705 return this._hashCode(dart.as(key, K)) & 0x3ffffff; | |
| 706 } | |
| 707 _findBucketIndex(bucket, key) { | |
| 708 if (bucket === null) | |
| 709 return -1; | |
| 710 let length = bucket.length; | |
| 711 for (let i = 0; i < length; i++) { | |
| 712 let cell = dart.as(bucket[i], LinkedHashMapCell); | |
| 713 if (this._equals(dart.as(cell._key, K), dart.as(key, K))) | |
| 714 return i; | |
| 715 } | |
| 716 return -1; | |
| 717 } | |
| 718 } | |
| 719 return _LinkedCustomHashMap; | |
| 720 }); | |
| 721 let _LinkedCustomHashMap = _LinkedCustomHashMap$(dynamic, dynamic); | |
| 722 class LinkedHashMapCell extends dart.Object { | |
| 723 LinkedHashMapCell(_key, _value) { | |
| 724 this._key = _key; | |
| 725 this._value = _value; | |
| 726 this._next = null; | |
| 727 this._previous = null; | |
| 728 } | |
| 729 } | |
| 730 let LinkedHashMapKeyIterable$ = dart.generic(function(E) { | |
| 731 class LinkedHashMapKeyIterable extends IterableBase$(E) { | |
| 732 LinkedHashMapKeyIterable(_map) { | |
| 733 this._map = _map; | |
| 734 super.IterableBase(); | |
| 735 } | |
| 736 get length() { | |
| 737 return dart.as(dart.dload(this._map, '_length'), core.int); | |
| 738 } | |
| 739 get isEmpty() { | |
| 740 return dart.equals(dart.dload(this._map, '_length'), 0); | |
| 741 } | |
| 742 get iterator() { | |
| 743 return new LinkedHashMapKeyIterator(this._map, dart.as(dart.dload(this._
map, '_modifications'), core.int)); | |
| 744 } | |
| 745 contains(element) { | |
| 746 return dart.as(dart.dinvoke(this._map, 'containsKey', element), core.boo
l); | |
| 747 } | |
| 748 forEach(f) { | |
| 749 let cell = dart.as(dart.dload(this._map, '_first'), LinkedHashMapCell); | |
| 750 let modifications = dart.as(dart.dload(this._map, '_modifications'), cor
e.int); | |
| 751 while (cell !== null) { | |
| 752 f(dart.as(cell._key, E)); | |
| 753 if (modifications !== dart.dload(this._map, '_modifications')) { | |
| 754 throw new core.ConcurrentModificationError(this._map); | |
| 755 } | |
| 756 cell = cell._next; | |
| 757 } | |
| 758 } | |
| 759 } | |
| 760 return LinkedHashMapKeyIterable; | |
| 761 }); | |
| 762 let LinkedHashMapKeyIterable = LinkedHashMapKeyIterable$(dynamic); | |
| 763 let LinkedHashMapKeyIterator$ = dart.generic(function(E) { | |
| 764 class LinkedHashMapKeyIterator extends dart.Object { | |
| 765 LinkedHashMapKeyIterator(_map, _modifications) { | |
| 766 this._map = _map; | |
| 767 this._modifications = _modifications; | |
| 768 this._cell = null; | |
| 769 this._current = dart.as(null, E); | |
| 770 this._cell = dart.as(dart.dload(this._map, '_first'), LinkedHashMapCell)
; | |
| 771 } | |
| 772 get current() { | |
| 773 return this._current; | |
| 774 } | |
| 775 moveNext() { | |
| 776 if (this._modifications !== dart.dload(this._map, '_modifications')) { | |
| 777 throw new core.ConcurrentModificationError(this._map); | |
| 778 } else if (this._cell === null) { | |
| 779 this._current = dart.as(null, E); | |
| 780 return false; | |
| 781 } else { | |
| 782 this._current = dart.as(this._cell._key, E); | |
| 783 this._cell = this._cell._next; | |
| 784 return true; | |
| 785 } | |
| 786 } | |
| 787 } | |
| 788 return LinkedHashMapKeyIterator; | |
| 789 }); | |
| 790 let LinkedHashMapKeyIterator = LinkedHashMapKeyIterator$(dynamic); | |
| 791 let _HashSet$ = dart.generic(function(E) { | |
| 792 class _HashSet extends _HashSetBase$(E) { | |
| 793 _HashSet() { | |
| 794 this._length = 0; | |
| 795 this._strings = null; | |
| 796 this._nums = null; | |
| 797 this._rest = null; | |
| 798 this._elements = null; | |
| 799 super._HashSetBase(); | |
| 800 } | |
| 801 _newSet() { | |
| 802 return new _HashSet(); | |
| 803 } | |
| 804 get iterator() { | |
| 805 return new HashSetIterator(this, this._computeElements()); | |
| 806 } | |
| 807 get length() { | |
| 808 return this._length; | |
| 809 } | |
| 810 get isEmpty() { | |
| 811 return this._length === 0; | |
| 812 } | |
| 813 get isNotEmpty() { | |
| 814 return !dart.notNull(this.isEmpty); | |
| 815 } | |
| 816 contains(object) { | |
| 817 if (_isStringElement(object)) { | |
| 818 let strings = this._strings; | |
| 819 return strings === null ? false : _hasTableEntry(strings, object); | |
| 820 } else if (_isNumericElement(object)) { | |
| 821 let nums = this._nums; | |
| 822 return nums === null ? false : _hasTableEntry(nums, object); | |
| 823 } else { | |
| 824 return this._contains(object); | |
| 825 } | |
| 826 } | |
| 827 _contains(object) { | |
| 828 let rest = this._rest; | |
| 829 if (rest === null) | |
| 830 return false; | |
| 831 let bucket = this._getBucket(rest, object); | |
| 832 return this._findBucketIndex(bucket, object) >= 0; | |
| 833 } | |
| 834 lookup(object) { | |
| 835 if (dart.notNull(_isStringElement(object)) || dart.notNull(_isNumericEle
ment(object))) { | |
| 836 return dart.as(this.contains(object) ? object : null, E); | |
| 837 } | |
| 838 return this._lookup(object); | |
| 839 } | |
| 840 _lookup(object) { | |
| 841 let rest = this._rest; | |
| 842 if (rest === null) | |
| 843 return dart.as(null, E); | |
| 844 let bucket = this._getBucket(rest, object); | |
| 845 let index = this._findBucketIndex(bucket, object); | |
| 846 if (index < 0) | |
| 847 return dart.as(null, E); | |
| 848 return dart.as(bucket.get(index), E); | |
| 849 } | |
| 850 add(element) { | |
| 851 if (_isStringElement(element)) { | |
| 852 let strings = this._strings; | |
| 853 if (strings === null) | |
| 854 this._strings = strings = _newHashTable(); | |
| 855 return this._addHashTableEntry(strings, element); | |
| 856 } else if (_isNumericElement(element)) { | |
| 857 let nums = this._nums; | |
| 858 if (nums === null) | |
| 859 this._nums = nums = _newHashTable(); | |
| 860 return this._addHashTableEntry(nums, element); | |
| 861 } else { | |
| 862 return this._add(element); | |
| 863 } | |
| 864 } | |
| 865 _add(element) { | |
| 866 let rest = this._rest; | |
| 867 if (rest === null) | |
| 868 this._rest = rest = _newHashTable(); | |
| 869 let hash = this._computeHashCode(element); | |
| 870 let bucket = rest[hash]; | |
| 871 if (bucket === null) { | |
| 872 _setTableEntry(rest, hash, [element]); | |
| 873 } else { | |
| 874 let index = this._findBucketIndex(bucket, element); | |
| 875 if (index >= 0) | |
| 876 return false; | |
| 877 bucket.push(element); | |
| 878 } | |
| 879 this._length++; | |
| 880 this._elements = null; | |
| 881 return true; | |
| 882 } | |
| 883 addAll(objects) { | |
| 884 for (let each of objects) { | |
| 885 this.add(each); | |
| 886 } | |
| 887 } | |
| 888 remove(object) { | |
| 889 if (_isStringElement(object)) { | |
| 890 return this._removeHashTableEntry(this._strings, object); | |
| 891 } else if (_isNumericElement(object)) { | |
| 892 return this._removeHashTableEntry(this._nums, object); | |
| 893 } else { | |
| 894 return this._remove(object); | |
| 895 } | |
| 896 } | |
| 897 _remove(object) { | |
| 898 let rest = this._rest; | |
| 899 if (rest === null) | |
| 900 return false; | |
| 901 let bucket = this._getBucket(rest, object); | |
| 902 let index = this._findBucketIndex(bucket, object); | |
| 903 if (index < 0) | |
| 904 return false; | |
| 905 this._length--; | |
| 906 this._elements = null; | |
| 907 bucket.splice(index, 1); | |
| 908 return true; | |
| 909 } | |
| 910 clear() { | |
| 911 if (this._length > 0) { | |
| 912 this._strings = this._nums = this._rest = this._elements = null; | |
| 913 this._length = 0; | |
| 914 } | |
| 915 } | |
| 916 _computeElements() { | |
| 917 if (this._elements !== null) | |
| 918 return this._elements; | |
| 919 let result = new core.List(this._length); | |
| 920 let index = 0; | |
| 921 let strings = this._strings; | |
| 922 if (strings !== null) { | |
| 923 let names = Object.getOwnPropertyNames(strings); | |
| 924 let entries = names.length; | |
| 925 for (let i = 0; i < entries; i++) { | |
| 926 let element = names[i]; | |
| 927 result[index] = element; | |
| 928 index++; | |
| 929 } | |
| 930 } | |
| 931 let nums = this._nums; | |
| 932 if (nums !== null) { | |
| 933 let names = Object.getOwnPropertyNames(nums); | |
| 934 let entries = names.length; | |
| 935 for (let i = 0; i < entries; i++) { | |
| 936 let element = +names[i]; | |
| 937 result[index] = element; | |
| 938 index++; | |
| 939 } | |
| 940 } | |
| 941 let rest = this._rest; | |
| 942 if (rest !== null) { | |
| 943 let names = Object.getOwnPropertyNames(rest); | |
| 944 let entries = names.length; | |
| 945 for (let i = 0; i < entries; i++) { | |
| 946 let entry = names[i]; | |
| 947 let bucket = rest[entry]; | |
| 948 let length = bucket.length; | |
| 949 for (let i = 0; i < length; i++) { | |
| 950 result[index] = bucket[i]; | |
| 951 index++; | |
| 952 } | |
| 953 } | |
| 954 } | |
| 955 dart.assert(index === this._length); | |
| 956 return this._elements = result; | |
| 957 } | |
| 958 _addHashTableEntry(table, element) { | |
| 959 if (_hasTableEntry(table, element)) | |
| 960 return false; | |
| 961 _setTableEntry(table, element, 0); | |
| 962 this._length++; | |
| 963 this._elements = null; | |
| 964 return true; | |
| 965 } | |
| 966 _removeHashTableEntry(table, element) { | |
| 967 if (dart.notNull(table !== null) && dart.notNull(_hasTableEntry(table, e
lement))) { | |
| 968 _deleteTableEntry(table, element); | |
| 969 this._length--; | |
| 970 this._elements = null; | |
| 971 return true; | |
| 972 } else { | |
| 973 return false; | |
| 974 } | |
| 975 } | |
| 976 static _isStringElement(element) { | |
| 977 return dart.notNull(typeof element == string) && dart.notNull(!dart.equa
ls(element, '__proto__')); | |
| 978 } | |
| 979 static _isNumericElement(element) { | |
| 980 return dart.notNull(dart.is(element, core.num)) && dart.notNull((element
& 0x3ffffff) === element); | |
| 981 } | |
| 982 _computeHashCode(element) { | |
| 983 return dart.dload(element, 'hashCode') & 0x3ffffff; | |
| 984 } | |
| 985 static _hasTableEntry(table, key) { | |
| 986 let entry = table[key]; | |
| 987 return entry !== null; | |
| 988 } | |
| 989 static _setTableEntry(table, key, value) { | |
| 990 dart.assert(value !== null); | |
| 991 table[key] = value; | |
| 992 } | |
| 993 static _deleteTableEntry(table, key) { | |
| 994 delete table[key]; | |
| 995 } | |
| 996 _getBucket(table, element) { | |
| 997 let hash = this._computeHashCode(element); | |
| 998 return dart.as(table[hash], core.List); | |
| 999 } | |
| 1000 _findBucketIndex(bucket, element) { | |
| 1001 if (bucket === null) | |
| 1002 return -1; | |
| 1003 let length = bucket.length; | |
| 1004 for (let i = 0; i < length; i++) { | |
| 1005 if (dart.equals(bucket[i], element)) | |
| 1006 return i; | |
| 1007 } | |
| 1008 return -1; | |
| 1009 } | |
| 1010 static _newHashTable() { | |
| 1011 let table = Object.create(null); | |
| 1012 let temporaryKey = '<non-identifier-key>'; | |
| 1013 _setTableEntry(table, temporaryKey, table); | |
| 1014 _deleteTableEntry(table, temporaryKey); | |
| 1015 return table; | |
| 1016 } | |
| 1017 } | |
| 1018 return _HashSet; | |
| 1019 }); | |
| 1020 let _HashSet = _HashSet$(dynamic); | |
| 1021 let _IdentityHashSet$ = dart.generic(function(E) { | |
| 1022 class _IdentityHashSet extends _HashSet$(E) { | |
| 1023 _newSet() { | |
| 1024 return new _IdentityHashSet(); | |
| 1025 } | |
| 1026 _computeHashCode(key) { | |
| 1027 return core.identityHashCode(key) & 0x3ffffff; | |
| 1028 } | |
| 1029 _findBucketIndex(bucket, element) { | |
| 1030 if (bucket === null) | |
| 1031 return -1; | |
| 1032 let length = bucket.length; | |
| 1033 for (let i = 0; i < length; i++) { | |
| 1034 if (core.identical(bucket[i], element)) | |
| 1035 return i; | |
| 1036 } | |
| 1037 return -1; | |
| 1038 } | |
| 1039 } | |
| 1040 return _IdentityHashSet; | |
| 1041 }); | |
| 1042 let _IdentityHashSet = _IdentityHashSet$(dynamic); | |
| 1043 let _CustomHashSet$ = dart.generic(function(E) { | |
| 1044 class _CustomHashSet extends _HashSet$(E) { | |
| 1045 _CustomHashSet(_equality, _hasher, validKey) { | |
| 1046 this._equality = _equality; | |
| 1047 this._hasher = _hasher; | |
| 1048 this._validKey = dart.as(validKey !== null ? validKey : (x) => dart.is(x
, E), _Predicate); | |
| 1049 super._HashSet(); | |
| 1050 } | |
| 1051 _newSet() { | |
| 1052 return new _CustomHashSet(this._equality, this._hasher, this._validKey); | |
| 1053 } | |
| 1054 _findBucketIndex(bucket, element) { | |
| 1055 if (bucket === null) | |
| 1056 return -1; | |
| 1057 let length = bucket.length; | |
| 1058 for (let i = 0; i < length; i++) { | |
| 1059 if (this._equality(dart.as(bucket[i], E), dart.as(element, E))) | |
| 1060 return i; | |
| 1061 } | |
| 1062 return -1; | |
| 1063 } | |
| 1064 _computeHashCode(element) { | |
| 1065 return this._hasher(dart.as(element, E)) & 0x3ffffff; | |
| 1066 } | |
| 1067 add(object) { | |
| 1068 return super._add(object); | |
| 1069 } | |
| 1070 contains(object) { | |
| 1071 if (!dart.notNull(this._validKey(object))) | |
| 1072 return false; | |
| 1073 return super._contains(object); | |
| 1074 } | |
| 1075 lookup(object) { | |
| 1076 if (!dart.notNull(this._validKey(object))) | |
| 1077 return dart.as(null, E); | |
| 1078 return super._lookup(object); | |
| 1079 } | |
| 1080 remove(object) { | |
| 1081 if (!dart.notNull(this._validKey(object))) | |
| 1082 return false; | |
| 1083 return super._remove(object); | |
| 1084 } | |
| 1085 } | |
| 1086 return _CustomHashSet; | |
| 1087 }); | |
| 1088 let _CustomHashSet = _CustomHashSet$(dynamic); | |
| 1089 let HashSetIterator$ = dart.generic(function(E) { | |
| 1090 class HashSetIterator extends dart.Object { | |
| 1091 HashSetIterator(_set, _elements) { | |
| 1092 this._set = _set; | |
| 1093 this._elements = _elements; | |
| 1094 this._offset = 0; | |
| 1095 this._current = dart.as(null, E); | |
| 1096 } | |
| 1097 get current() { | |
| 1098 return this._current; | |
| 1099 } | |
| 1100 moveNext() { | |
| 1101 let elements = this._elements; | |
| 1102 let offset = this._offset; | |
| 1103 if (elements !== dart.dload(this._set, '_elements')) { | |
| 1104 throw new core.ConcurrentModificationError(this._set); | |
| 1105 } else if (offset >= elements.length) { | |
| 1106 this._current = dart.as(null, E); | |
| 1107 return false; | |
| 1108 } else { | |
| 1109 this._current = dart.as(elements[offset], E); | |
| 1110 this._offset = offset + 1; | |
| 1111 return true; | |
| 1112 } | |
| 1113 } | |
| 1114 } | |
| 1115 return HashSetIterator; | |
| 1116 }); | |
| 1117 let HashSetIterator = HashSetIterator$(dynamic); | |
| 1118 let _LinkedHashSet$ = dart.generic(function(E) { | |
| 1119 class _LinkedHashSet extends _HashSetBase$(E) { | |
| 1120 _LinkedHashSet() { | |
| 1121 this._length = 0; | |
| 1122 this._strings = null; | |
| 1123 this._nums = null; | |
| 1124 this._rest = null; | |
| 1125 this._first = null; | |
| 1126 this._last = null; | |
| 1127 this._modifications = 0; | |
| 1128 super._HashSetBase(); | |
| 1129 } | |
| 1130 _newSet() { | |
| 1131 return new _LinkedHashSet(); | |
| 1132 } | |
| 1133 _unsupported(operation) { | |
| 1134 throw `LinkedHashSet: unsupported ${operation}`; | |
| 1135 } | |
| 1136 get iterator() { | |
| 1137 return dart.as(new LinkedHashSetIterator(this, this._modifications), cor
e.Iterator$(E)); | |
| 1138 } | |
| 1139 get length() { | |
| 1140 return this._length; | |
| 1141 } | |
| 1142 get isEmpty() { | |
| 1143 return this._length === 0; | |
| 1144 } | |
| 1145 get isNotEmpty() { | |
| 1146 return !dart.notNull(this.isEmpty); | |
| 1147 } | |
| 1148 contains(object) { | |
| 1149 if (_isStringElement(object)) { | |
| 1150 let strings = this._strings; | |
| 1151 if (strings === null) | |
| 1152 return false; | |
| 1153 let cell = dart.as(_getTableEntry(strings, object), LinkedHashSetCell)
; | |
| 1154 return cell !== null; | |
| 1155 } else if (_isNumericElement(object)) { | |
| 1156 let nums = this._nums; | |
| 1157 if (nums === null) | |
| 1158 return false; | |
| 1159 let cell = dart.as(_getTableEntry(nums, object), LinkedHashSetCell); | |
| 1160 return cell !== null; | |
| 1161 } else { | |
| 1162 return this._contains(object); | |
| 1163 } | |
| 1164 } | |
| 1165 _contains(object) { | |
| 1166 let rest = this._rest; | |
| 1167 if (rest === null) | |
| 1168 return false; | |
| 1169 let bucket = this._getBucket(rest, object); | |
| 1170 return this._findBucketIndex(bucket, object) >= 0; | |
| 1171 } | |
| 1172 lookup(object) { | |
| 1173 if (dart.notNull(_isStringElement(object)) || dart.notNull(_isNumericEle
ment(object))) { | |
| 1174 return dart.as(this.contains(object) ? object : null, E); | |
| 1175 } else { | |
| 1176 return this._lookup(object); | |
| 1177 } | |
| 1178 } | |
| 1179 _lookup(object) { | |
| 1180 let rest = this._rest; | |
| 1181 if (rest === null) | |
| 1182 return dart.as(null, E); | |
| 1183 let bucket = this._getBucket(rest, object); | |
| 1184 let index = this._findBucketIndex(bucket, object); | |
| 1185 if (index < 0) | |
| 1186 return dart.as(null, E); | |
| 1187 return dart.as(dart.dload(bucket.get(index), '_element'), E); | |
| 1188 } | |
| 1189 forEach(action) { | |
| 1190 let cell = this._first; | |
| 1191 let modifications = this._modifications; | |
| 1192 while (cell !== null) { | |
| 1193 action(dart.as(cell._element, E)); | |
| 1194 if (modifications !== this._modifications) { | |
| 1195 throw new core.ConcurrentModificationError(this); | |
| 1196 } | |
| 1197 cell = cell._next; | |
| 1198 } | |
| 1199 } | |
| 1200 get first() { | |
| 1201 if (this._first === null) | |
| 1202 throw new core.StateError("No elements"); | |
| 1203 return dart.as(this._first._element, E); | |
| 1204 } | |
| 1205 get last() { | |
| 1206 if (this._last === null) | |
| 1207 throw new core.StateError("No elements"); | |
| 1208 return dart.as(this._last._element, E); | |
| 1209 } | |
| 1210 add(element) { | |
| 1211 if (_isStringElement(element)) { | |
| 1212 let strings = this._strings; | |
| 1213 if (strings === null) | |
| 1214 this._strings = strings = _newHashTable(); | |
| 1215 return this._addHashTableEntry(strings, element); | |
| 1216 } else if (_isNumericElement(element)) { | |
| 1217 let nums = this._nums; | |
| 1218 if (nums === null) | |
| 1219 this._nums = nums = _newHashTable(); | |
| 1220 return this._addHashTableEntry(nums, element); | |
| 1221 } else { | |
| 1222 return this._add(element); | |
| 1223 } | |
| 1224 } | |
| 1225 _add(element) { | |
| 1226 let rest = this._rest; | |
| 1227 if (rest === null) | |
| 1228 this._rest = rest = _newHashTable(); | |
| 1229 let hash = this._computeHashCode(element); | |
| 1230 let bucket = rest[hash]; | |
| 1231 if (bucket === null) { | |
| 1232 let cell = this._newLinkedCell(element); | |
| 1233 _setTableEntry(rest, hash, [cell]); | |
| 1234 } else { | |
| 1235 let index = this._findBucketIndex(bucket, element); | |
| 1236 if (index >= 0) | |
| 1237 return false; | |
| 1238 let cell = this._newLinkedCell(element); | |
| 1239 bucket.push(cell); | |
| 1240 } | |
| 1241 return true; | |
| 1242 } | |
| 1243 remove(object) { | |
| 1244 if (_isStringElement(object)) { | |
| 1245 return this._removeHashTableEntry(this._strings, object); | |
| 1246 } else if (_isNumericElement(object)) { | |
| 1247 return this._removeHashTableEntry(this._nums, object); | |
| 1248 } else { | |
| 1249 return this._remove(object); | |
| 1250 } | |
| 1251 } | |
| 1252 _remove(object) { | |
| 1253 let rest = this._rest; | |
| 1254 if (rest === null) | |
| 1255 return false; | |
| 1256 let bucket = this._getBucket(rest, object); | |
| 1257 let index = this._findBucketIndex(bucket, object); | |
| 1258 if (index < 0) | |
| 1259 return false; | |
| 1260 let cell = dart.as(bucket.splice(index, 1)[0], LinkedHashSetCell); | |
| 1261 this._unlinkCell(cell); | |
| 1262 return true; | |
| 1263 } | |
| 1264 removeWhere(test) { | |
| 1265 this._filterWhere(test, true); | |
| 1266 } | |
| 1267 retainWhere(test) { | |
| 1268 this._filterWhere(test, false); | |
| 1269 } | |
| 1270 _filterWhere(test, removeMatching) { | |
| 1271 let cell = this._first; | |
| 1272 while (cell !== null) { | |
| 1273 let element = dart.as(cell._element, E); | |
| 1274 let next = cell._next; | |
| 1275 let modifications = this._modifications; | |
| 1276 let shouldRemove = removeMatching === test(element); | |
| 1277 if (modifications !== this._modifications) { | |
| 1278 throw new core.ConcurrentModificationError(this); | |
| 1279 } | |
| 1280 if (shouldRemove) | |
| 1281 this.remove(element); | |
| 1282 cell = next; | |
| 1283 } | |
| 1284 } | |
| 1285 clear() { | |
| 1286 if (this._length > 0) { | |
| 1287 this._strings = this._nums = this._rest = this._first = this._last = n
ull; | |
| 1288 this._length = 0; | |
| 1289 this._modified(); | |
| 1290 } | |
| 1291 } | |
| 1292 _addHashTableEntry(table, element) { | |
| 1293 let cell = dart.as(_getTableEntry(table, element), LinkedHashSetCell); | |
| 1294 if (cell !== null) | |
| 1295 return false; | |
| 1296 _setTableEntry(table, element, this._newLinkedCell(element)); | |
| 1297 return true; | |
| 1298 } | |
| 1299 _removeHashTableEntry(table, element) { | |
| 1300 if (table === null) | |
| 1301 return false; | |
| 1302 let cell = dart.as(_getTableEntry(table, element), LinkedHashSetCell); | |
| 1303 if (cell === null) | |
| 1304 return false; | |
| 1305 this._unlinkCell(cell); | |
| 1306 _deleteTableEntry(table, element); | |
| 1307 return true; | |
| 1308 } | |
| 1309 _modified() { | |
| 1310 this._modifications = this._modifications + 1 & 67108863; | |
| 1311 } | |
| 1312 _newLinkedCell(element) { | |
| 1313 let cell = new LinkedHashSetCell(element); | |
| 1314 if (this._first === null) { | |
| 1315 this._first = this._last = cell; | |
| 1316 } else { | |
| 1317 let last = this._last; | |
| 1318 cell._previous = last; | |
| 1319 this._last = last._next = cell; | |
| 1320 } | |
| 1321 this._length++; | |
| 1322 this._modified(); | |
| 1323 return cell; | |
| 1324 } | |
| 1325 _unlinkCell(cell) { | |
| 1326 let previous = cell._previous; | |
| 1327 let next = cell._next; | |
| 1328 if (previous === null) { | |
| 1329 dart.assert(dart.equals(cell, this._first)); | |
| 1330 this._first = next; | |
| 1331 } else { | |
| 1332 previous._next = next; | |
| 1333 } | |
| 1334 if (next === null) { | |
| 1335 dart.assert(dart.equals(cell, this._last)); | |
| 1336 this._last = previous; | |
| 1337 } else { | |
| 1338 next._previous = previous; | |
| 1339 } | |
| 1340 this._length--; | |
| 1341 this._modified(); | |
| 1342 } | |
| 1343 static _isStringElement(element) { | |
| 1344 return dart.notNull(typeof element == string) && dart.notNull(!dart.equa
ls(element, '__proto__')); | |
| 1345 } | |
| 1346 static _isNumericElement(element) { | |
| 1347 return dart.notNull(dart.is(element, core.num)) && dart.notNull((element
& 0x3ffffff) === element); | |
| 1348 } | |
| 1349 _computeHashCode(element) { | |
| 1350 return dart.dload(element, 'hashCode') & 0x3ffffff; | |
| 1351 } | |
| 1352 static _getTableEntry(table, key) { | |
| 1353 return table[key]; | |
| 1354 } | |
| 1355 static _setTableEntry(table, key, value) { | |
| 1356 dart.assert(value !== null); | |
| 1357 table[key] = value; | |
| 1358 } | |
| 1359 static _deleteTableEntry(table, key) { | |
| 1360 delete table[key]; | |
| 1361 } | |
| 1362 _getBucket(table, element) { | |
| 1363 let hash = this._computeHashCode(element); | |
| 1364 return dart.as(table[hash], core.List); | |
| 1365 } | |
| 1366 _findBucketIndex(bucket, element) { | |
| 1367 if (bucket === null) | |
| 1368 return -1; | |
| 1369 let length = bucket.length; | |
| 1370 for (let i = 0; i < length; i++) { | |
| 1371 let cell = dart.as(bucket[i], LinkedHashSetCell); | |
| 1372 if (dart.equals(cell._element, element)) | |
| 1373 return i; | |
| 1374 } | |
| 1375 return -1; | |
| 1376 } | |
| 1377 static _newHashTable() { | |
| 1378 let table = Object.create(null); | |
| 1379 let temporaryKey = '<non-identifier-key>'; | |
| 1380 _setTableEntry(table, temporaryKey, table); | |
| 1381 _deleteTableEntry(table, temporaryKey); | |
| 1382 return table; | |
| 1383 } | |
| 1384 } | |
| 1385 return _LinkedHashSet; | |
| 1386 }); | |
| 1387 let _LinkedHashSet = _LinkedHashSet$(dynamic); | |
| 1388 let _LinkedIdentityHashSet$ = dart.generic(function(E) { | |
| 1389 class _LinkedIdentityHashSet extends _LinkedHashSet$(E) { | |
| 1390 _newSet() { | |
| 1391 return new _LinkedIdentityHashSet(); | |
| 1392 } | |
| 1393 _computeHashCode(key) { | |
| 1394 return core.identityHashCode(key) & 0x3ffffff; | |
| 1395 } | |
| 1396 _findBucketIndex(bucket, element) { | |
| 1397 if (bucket === null) | |
| 1398 return -1; | |
| 1399 let length = bucket.length; | |
| 1400 for (let i = 0; i < length; i++) { | |
| 1401 let cell = dart.as(bucket[i], LinkedHashSetCell); | |
| 1402 if (core.identical(cell._element, element)) | |
| 1403 return i; | |
| 1404 } | |
| 1405 return -1; | |
| 1406 } | |
| 1407 } | |
| 1408 return _LinkedIdentityHashSet; | |
| 1409 }); | |
| 1410 let _LinkedIdentityHashSet = _LinkedIdentityHashSet$(dynamic); | |
| 1411 let _LinkedCustomHashSet$ = dart.generic(function(E) { | |
| 1412 class _LinkedCustomHashSet extends _LinkedHashSet$(E) { | |
| 1413 _LinkedCustomHashSet(_equality, _hasher, validKey) { | |
| 1414 this._equality = _equality; | |
| 1415 this._hasher = _hasher; | |
| 1416 this._validKey = dart.as(validKey !== null ? validKey : (x) => dart.is(x
, E), _Predicate); | |
| 1417 super._LinkedHashSet(); | |
| 1418 } | |
| 1419 _newSet() { | |
| 1420 return new _LinkedCustomHashSet(this._equality, this._hasher, this._vali
dKey); | |
| 1421 } | |
| 1422 _findBucketIndex(bucket, element) { | |
| 1423 if (bucket === null) | |
| 1424 return -1; | |
| 1425 let length = bucket.length; | |
| 1426 for (let i = 0; i < length; i++) { | |
| 1427 let cell = dart.as(bucket[i], LinkedHashSetCell); | |
| 1428 if (this._equality(dart.as(cell._element, E), dart.as(element, E))) | |
| 1429 return i; | |
| 1430 } | |
| 1431 return -1; | |
| 1432 } | |
| 1433 _computeHashCode(element) { | |
| 1434 return this._hasher(dart.as(element, E)) & 0x3ffffff; | |
| 1435 } | |
| 1436 add(element) { | |
| 1437 return super._add(element); | |
| 1438 } | |
| 1439 contains(object) { | |
| 1440 if (!dart.notNull(this._validKey(object))) | |
| 1441 return false; | |
| 1442 return super._contains(object); | |
| 1443 } | |
| 1444 lookup(object) { | |
| 1445 if (!dart.notNull(this._validKey(object))) | |
| 1446 return dart.as(null, E); | |
| 1447 return super._lookup(object); | |
| 1448 } | |
| 1449 remove(object) { | |
| 1450 if (!dart.notNull(this._validKey(object))) | |
| 1451 return false; | |
| 1452 return super._remove(object); | |
| 1453 } | |
| 1454 containsAll(elements) { | |
| 1455 for (let element of elements) { | |
| 1456 if (dart.notNull(!dart.notNull(this._validKey(element))) || dart.notNu
ll(!dart.notNull(this.contains(element)))) | |
| 1457 return false; | |
| 1458 } | |
| 1459 return true; | |
| 1460 } | |
| 1461 removeAll(elements) { | |
| 1462 for (let element of elements) { | |
| 1463 if (this._validKey(element)) { | |
| 1464 super._remove(element); | |
| 1465 } | |
| 1466 } | |
| 1467 } | |
| 1468 } | |
| 1469 return _LinkedCustomHashSet; | |
| 1470 }); | |
| 1471 let _LinkedCustomHashSet = _LinkedCustomHashSet$(dynamic); | |
| 1472 class LinkedHashSetCell extends dart.Object { | |
| 1473 LinkedHashSetCell(_element) { | |
| 1474 this._element = _element; | |
| 1475 this._next = null; | |
| 1476 this._previous = null; | |
| 1477 } | |
| 1478 } | |
| 1479 let LinkedHashSetIterator$ = dart.generic(function(E) { | |
| 1480 class LinkedHashSetIterator extends dart.Object { | |
| 1481 LinkedHashSetIterator(_set, _modifications) { | |
| 1482 this._set = _set; | |
| 1483 this._modifications = _modifications; | |
| 1484 this._cell = null; | |
| 1485 this._current = dart.as(null, E); | |
| 1486 this._cell = dart.as(dart.dload(this._set, '_first'), LinkedHashSetCell)
; | |
| 1487 } | |
| 1488 get current() { | |
| 1489 return this._current; | |
| 1490 } | |
| 1491 moveNext() { | |
| 1492 if (this._modifications !== dart.dload(this._set, '_modifications')) { | |
| 1493 throw new core.ConcurrentModificationError(this._set); | |
| 1494 } else if (this._cell === null) { | |
| 1495 this._current = dart.as(null, E); | |
| 1496 return false; | |
| 1497 } else { | |
| 1498 this._current = dart.as(this._cell._element, E); | |
| 1499 this._cell = this._cell._next; | |
| 1500 return true; | |
| 1501 } | |
| 1502 } | |
| 1503 } | |
| 1504 return LinkedHashSetIterator; | |
| 1505 }); | |
| 1506 let LinkedHashSetIterator = LinkedHashSetIterator$(dynamic); | |
| 1507 let UnmodifiableListView$ = dart.generic(function(E) { | |
| 1508 class UnmodifiableListView extends _internal.UnmodifiableListBase$(E) { | |
| 1509 UnmodifiableListView(source) { | |
| 1510 this._source = source; | |
| 1511 super.UnmodifiableListBase(); | |
| 1512 } | |
| 1513 get length() { | |
| 1514 return this._source.length; | |
| 1515 } | |
| 1516 get(index) { | |
| 1517 return this._source.elementAt(index); | |
| 1518 } | |
| 1519 } | |
| 1520 return UnmodifiableListView; | |
| 1521 }); | |
| 1522 let UnmodifiableListView = UnmodifiableListView$(dynamic); | |
| 1523 // Function _defaultEquals: (dynamic, dynamic) → bool | |
| 1524 function _defaultEquals(a, b) { | |
| 1525 return dart.equals(a, b); | |
| 1526 } | |
| 1527 // Function _defaultHashCode: (dynamic) → int | |
| 1528 function _defaultHashCode(a) { | |
| 1529 return dart.as(dart.dload(a, 'hashCode'), core.int); | |
| 1530 } | |
| 1531 let HashMap$ = dart.generic(function(K, V) { | |
| 1532 class HashMap extends dart.Object { | |
| 1533 HashMap(opt$) { | |
| 1534 let equals = opt$.equals === void 0 ? null : opt$.equals; | |
| 1535 let hashCode = opt$.hashCode === void 0 ? null : opt$.hashCode; | |
| 1536 let isValidKey = opt$.isValidKey === void 0 ? null : opt$.isValidKey; | |
| 1537 if (isValidKey === null) { | |
| 1538 if (hashCode === null) { | |
| 1539 if (equals === null) { | |
| 1540 return new _HashMap(); | |
| 1541 } | |
| 1542 hashCode = _defaultHashCode; | |
| 1543 } else { | |
| 1544 if (dart.notNull(core.identical(core.identityHashCode, hashCode)) &&
dart.notNull(core.identical(core.identical, equals))) { | |
| 1545 return new _IdentityHashMap(); | |
| 1546 } | |
| 1547 if (equals === null) { | |
| 1548 equals = _defaultEquals; | |
| 1549 } | |
| 1550 } | |
| 1551 } else { | |
| 1552 if (hashCode === null) { | |
| 1553 hashCode = _defaultHashCode; | |
| 1554 } | |
| 1555 if (equals === null) { | |
| 1556 equals = _defaultEquals; | |
| 1557 } | |
| 1558 } | |
| 1559 return new _CustomHashMap(equals, hashCode, isValidKey); | |
| 1560 } | |
| 1561 HashMap$identity() { | |
| 1562 return new _IdentityHashMap(); | |
| 1563 } | |
| 1564 HashMap$from(other) { | |
| 1565 let result = new HashMap(); | |
| 1566 other.forEach((k, v) => { | |
| 1567 result.set(k, dart.as(v, V)); | |
| 1568 }); | |
| 1569 return result; | |
| 1570 } | |
| 1571 HashMap$fromIterable(iterable, opt$) { | |
| 1572 let key = opt$.key === void 0 ? null : opt$.key; | |
| 1573 let value = opt$.value === void 0 ? null : opt$.value; | |
| 1574 let map = new HashMap(); | |
| 1575 Maps._fillMapWithMappedIterable(map, iterable, key, value); | |
| 1576 return map; | |
| 1577 } | |
| 1578 HashMap$fromIterables(keys, values) { | |
| 1579 let map = new HashMap(); | |
| 1580 Maps._fillMapWithIterables(map, keys, values); | |
| 1581 return map; | |
| 1582 } | |
| 1583 } | |
| 1584 dart.defineNamedConstructor(HashMap, 'identity'); | |
| 1585 dart.defineNamedConstructor(HashMap, 'from'); | |
| 1586 dart.defineNamedConstructor(HashMap, 'fromIterable'); | |
| 1587 dart.defineNamedConstructor(HashMap, 'fromIterables'); | |
| 1588 return HashMap; | |
| 1589 }); | |
| 1590 let HashMap = HashMap$(dynamic, dynamic); | |
| 1591 let _HashSetBase$ = dart.generic(function(E) { | |
| 1592 class _HashSetBase extends SetBase$(E) { | |
| 1593 difference(other) { | |
| 1594 let result = this._newSet(); | |
| 1595 for (let element of this) { | |
| 1596 if (!dart.notNull(other.contains(element))) | |
| 1597 result.add(dart.as(element, E)); | |
| 1598 } | |
| 1599 return result; | |
| 1600 } | |
| 1601 intersection(other) { | |
| 1602 let result = this._newSet(); | |
| 1603 for (let element of this) { | |
| 1604 if (other.contains(element)) | |
| 1605 result.add(dart.as(element, E)); | |
| 1606 } | |
| 1607 return result; | |
| 1608 } | |
| 1609 toSet() { | |
| 1610 return ((_) => { | |
| 1611 _.addAll(this); | |
| 1612 return _; | |
| 1613 }).bind(this)(this._newSet()); | |
| 1614 } | |
| 1615 } | |
| 1616 return _HashSetBase; | |
| 1617 }); | |
| 1618 let _HashSetBase = _HashSetBase$(dynamic); | |
| 1619 let HashSet$ = dart.generic(function(E) { | |
| 1620 class HashSet extends dart.Object { | |
| 1621 HashSet(opt$) { | |
| 1622 let equals = opt$.equals === void 0 ? null : opt$.equals; | |
| 1623 let hashCode = opt$.hashCode === void 0 ? null : opt$.hashCode; | |
| 1624 let isValidKey = opt$.isValidKey === void 0 ? null : opt$.isValidKey; | |
| 1625 if (isValidKey === null) { | |
| 1626 if (hashCode === null) { | |
| 1627 if (equals === null) { | |
| 1628 return new _HashSet(); | |
| 1629 } | |
| 1630 hashCode = _defaultHashCode; | |
| 1631 } else { | |
| 1632 if (dart.notNull(core.identical(core.identityHashCode, hashCode)) &&
dart.notNull(core.identical(core.identical, equals))) { | |
| 1633 return new _IdentityHashSet(); | |
| 1634 } | |
| 1635 if (equals === null) { | |
| 1636 equals = _defaultEquals; | |
| 1637 } | |
| 1638 } | |
| 1639 } else { | |
| 1640 if (hashCode === null) { | |
| 1641 hashCode = _defaultHashCode; | |
| 1642 } | |
| 1643 if (equals === null) { | |
| 1644 equals = _defaultEquals; | |
| 1645 } | |
| 1646 } | |
| 1647 return new _CustomHashSet(equals, hashCode, isValidKey); | |
| 1648 } | |
| 1649 HashSet$identity() { | |
| 1650 return new _IdentityHashSet(); | |
| 1651 } | |
| 1652 HashSet$from(elements) { | |
| 1653 let result = new HashSet(); | |
| 1654 for (let e of elements) | |
| 1655 result.add(e); | |
| 1656 return result; | |
| 1657 } | |
| 1658 } | |
| 1659 dart.defineNamedConstructor(HashSet, 'identity'); | |
| 1660 dart.defineNamedConstructor(HashSet, 'from'); | |
| 1661 return HashSet; | |
| 1662 }); | |
| 1663 let HashSet = HashSet$(dynamic); | |
| 1664 let IterableMixin$ = dart.generic(function(E) { | |
| 1665 class IterableMixin extends dart.Object { | |
| 1666 map(f) { | |
| 1667 return new _internal.MappedIterable(this, f); | |
| 1668 } | |
| 1669 where(f) { | |
| 1670 return new _internal.WhereIterable(this, f); | |
| 1671 } | |
| 1672 expand(f) { | |
| 1673 return new _internal.ExpandIterable(this, f); | |
| 1674 } | |
| 1675 contains(element) { | |
| 1676 for (let e of this) { | |
| 1677 if (dart.equals(e, element)) | |
| 1678 return true; | |
| 1679 } | |
| 1680 return false; | |
| 1681 } | |
| 1682 forEach(f) { | |
| 1683 for (let element of this) | |
| 1684 f(element); | |
| 1685 } | |
| 1686 reduce(combine) { | |
| 1687 let iterator = this.iterator; | |
| 1688 if (!dart.notNull(iterator.moveNext())) { | |
| 1689 throw _internal.IterableElementError.noElement(); | |
| 1690 } | |
| 1691 let value = iterator.current; | |
| 1692 while (iterator.moveNext()) { | |
| 1693 value = combine(value, iterator.current); | |
| 1694 } | |
| 1695 return value; | |
| 1696 } | |
| 1697 fold(initialValue, combine) { | |
| 1698 let value = initialValue; | |
| 1699 for (let element of this) | |
| 1700 value = combine(value, element); | |
| 1701 return value; | |
| 1702 } | |
| 1703 every(f) { | |
| 1704 for (let element of this) { | |
| 1705 if (!dart.notNull(f(element))) | |
| 1706 return false; | |
| 1707 } | |
| 1708 return true; | |
| 1709 } | |
| 1710 join(separator) { | |
| 1711 if (separator === void 0) | |
| 1712 separator = ""; | |
| 1713 let iterator = this.iterator; | |
| 1714 if (!dart.notNull(iterator.moveNext())) | |
| 1715 return ""; | |
| 1716 let buffer = new core.StringBuffer(); | |
| 1717 if (dart.notNull(separator === null) || dart.notNull(dart.equals(separat
or, ""))) { | |
| 1718 do { | |
| 1719 buffer.write(`${iterator.current}`); | |
| 1720 } while (iterator.moveNext()); | |
| 1721 } else { | |
| 1722 buffer.write(`${iterator.current}`); | |
| 1723 while (iterator.moveNext()) { | |
| 1724 buffer.write(separator); | |
| 1725 buffer.write(`${iterator.current}`); | |
| 1726 } | |
| 1727 } | |
| 1728 return buffer.toString(); | |
| 1729 } | |
| 1730 any(f) { | |
| 1731 for (let element of this) { | |
| 1732 if (f(element)) | |
| 1733 return true; | |
| 1734 } | |
| 1735 return false; | |
| 1736 } | |
| 1737 toList(opt$) { | |
| 1738 let growable = opt$.growable === void 0 ? true : opt$.growable; | |
| 1739 return new core.List.from(this, {growable: growable}); | |
| 1740 } | |
| 1741 toSet() { | |
| 1742 return new core.Set.from(this); | |
| 1743 } | |
| 1744 get length() { | |
| 1745 dart.assert(!dart.is(this, _internal.EfficientLength)); | |
| 1746 let count = 0; | |
| 1747 let it = this.iterator; | |
| 1748 while (it.moveNext()) { | |
| 1749 count++; | |
| 1750 } | |
| 1751 return count; | |
| 1752 } | |
| 1753 get isEmpty() { | |
| 1754 return !dart.notNull(this.iterator.moveNext()); | |
| 1755 } | |
| 1756 get isNotEmpty() { | |
| 1757 return !dart.notNull(this.isEmpty); | |
| 1758 } | |
| 1759 take(n) { | |
| 1760 return new _internal.TakeIterable(this, n); | |
| 1761 } | |
| 1762 takeWhile(test) { | |
| 1763 return new _internal.TakeWhileIterable(this, test); | |
| 1764 } | |
| 1765 skip(n) { | |
| 1766 return new _internal.SkipIterable(this, n); | |
| 1767 } | |
| 1768 skipWhile(test) { | |
| 1769 return new _internal.SkipWhileIterable(this, test); | |
| 1770 } | |
| 1771 get first() { | |
| 1772 let it = this.iterator; | |
| 1773 if (!dart.notNull(it.moveNext())) { | |
| 1774 throw _internal.IterableElementError.noElement(); | |
| 1775 } | |
| 1776 return dart.as(it.current, E); | |
| 1777 } | |
| 1778 get last() { | |
| 1779 let it = this.iterator; | |
| 1780 if (!dart.notNull(it.moveNext())) { | |
| 1781 throw _internal.IterableElementError.noElement(); | |
| 1782 } | |
| 1783 let result = null; | |
| 1784 do { | |
| 1785 result = dart.as(it.current, E); | |
| 1786 } while (it.moveNext()); | |
| 1787 return result; | |
| 1788 } | |
| 1789 get single() { | |
| 1790 let it = this.iterator; | |
| 1791 if (!dart.notNull(it.moveNext())) | |
| 1792 throw _internal.IterableElementError.noElement(); | |
| 1793 let result = dart.as(it.current, E); | |
| 1794 if (it.moveNext()) | |
| 1795 throw _internal.IterableElementError.tooMany(); | |
| 1796 return result; | |
| 1797 } | |
| 1798 firstWhere(test, opt$) { | |
| 1799 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 1800 for (let element of this) { | |
| 1801 if (test(element)) | |
| 1802 return element; | |
| 1803 } | |
| 1804 if (orElse !== null) | |
| 1805 return orElse(); | |
| 1806 throw _internal.IterableElementError.noElement(); | |
| 1807 } | |
| 1808 lastWhere(test, opt$) { | |
| 1809 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 1810 let result = dart.as(null, E); | |
| 1811 let foundMatching = false; | |
| 1812 for (let element of this) { | |
| 1813 if (test(element)) { | |
| 1814 result = element; | |
| 1815 foundMatching = true; | |
| 1816 } | |
| 1817 } | |
| 1818 if (foundMatching) | |
| 1819 return result; | |
| 1820 if (orElse !== null) | |
| 1821 return orElse(); | |
| 1822 throw _internal.IterableElementError.noElement(); | |
| 1823 } | |
| 1824 singleWhere(test) { | |
| 1825 let result = dart.as(null, E); | |
| 1826 let foundMatching = false; | |
| 1827 for (let element of this) { | |
| 1828 if (test(element)) { | |
| 1829 if (foundMatching) { | |
| 1830 throw _internal.IterableElementError.tooMany(); | |
| 1831 } | |
| 1832 result = element; | |
| 1833 foundMatching = true; | |
| 1834 } | |
| 1835 } | |
| 1836 if (foundMatching) | |
| 1837 return result; | |
| 1838 throw _internal.IterableElementError.noElement(); | |
| 1839 } | |
| 1840 elementAt(index) { | |
| 1841 if (!(typeof index == number)) | |
| 1842 throw new core.ArgumentError.notNull("index"); | |
| 1843 core.RangeError.checkNotNegative(index, "index"); | |
| 1844 let elementIndex = 0; | |
| 1845 for (let element of this) { | |
| 1846 if (index === elementIndex) | |
| 1847 return element; | |
| 1848 elementIndex++; | |
| 1849 } | |
| 1850 throw new core.RangeError.index(index, this, "index", null, elementIndex
); | |
| 1851 } | |
| 1852 toString() { | |
| 1853 return IterableBase.iterableToShortString(this, '(', ')'); | |
| 1854 } | |
| 1855 } | |
| 1856 return IterableMixin; | |
| 1857 }); | |
| 1858 let IterableMixin = IterableMixin$(dynamic); | |
| 1859 let IterableBase$ = dart.generic(function(E) { | |
| 1860 class IterableBase extends dart.Object { | |
| 1861 IterableBase() { | |
| 1862 } | |
| 1863 map(f) { | |
| 1864 return new _internal.MappedIterable(this, f); | |
| 1865 } | |
| 1866 where(f) { | |
| 1867 return new _internal.WhereIterable(this, f); | |
| 1868 } | |
| 1869 expand(f) { | |
| 1870 return new _internal.ExpandIterable(this, f); | |
| 1871 } | |
| 1872 contains(element) { | |
| 1873 for (let e of this) { | |
| 1874 if (dart.equals(e, element)) | |
| 1875 return true; | |
| 1876 } | |
| 1877 return false; | |
| 1878 } | |
| 1879 forEach(f) { | |
| 1880 for (let element of this) | |
| 1881 f(element); | |
| 1882 } | |
| 1883 reduce(combine) { | |
| 1884 let iterator = this.iterator; | |
| 1885 if (!dart.notNull(iterator.moveNext())) { | |
| 1886 throw _internal.IterableElementError.noElement(); | |
| 1887 } | |
| 1888 let value = iterator.current; | |
| 1889 while (iterator.moveNext()) { | |
| 1890 value = combine(value, iterator.current); | |
| 1891 } | |
| 1892 return value; | |
| 1893 } | |
| 1894 fold(initialValue, combine) { | |
| 1895 let value = initialValue; | |
| 1896 for (let element of this) | |
| 1897 value = combine(value, element); | |
| 1898 return value; | |
| 1899 } | |
| 1900 every(f) { | |
| 1901 for (let element of this) { | |
| 1902 if (!dart.notNull(f(element))) | |
| 1903 return false; | |
| 1904 } | |
| 1905 return true; | |
| 1906 } | |
| 1907 join(separator) { | |
| 1908 if (separator === void 0) | |
| 1909 separator = ""; | |
| 1910 let iterator = this.iterator; | |
| 1911 if (!dart.notNull(iterator.moveNext())) | |
| 1912 return ""; | |
| 1913 let buffer = new core.StringBuffer(); | |
| 1914 if (dart.notNull(separator === null) || dart.notNull(dart.equals(separat
or, ""))) { | |
| 1915 do { | |
| 1916 buffer.write(`${iterator.current}`); | |
| 1917 } while (iterator.moveNext()); | |
| 1918 } else { | |
| 1919 buffer.write(`${iterator.current}`); | |
| 1920 while (iterator.moveNext()) { | |
| 1921 buffer.write(separator); | |
| 1922 buffer.write(`${iterator.current}`); | |
| 1923 } | |
| 1924 } | |
| 1925 return buffer.toString(); | |
| 1926 } | |
| 1927 any(f) { | |
| 1928 for (let element of this) { | |
| 1929 if (f(element)) | |
| 1930 return true; | |
| 1931 } | |
| 1932 return false; | |
| 1933 } | |
| 1934 toList(opt$) { | |
| 1935 let growable = opt$.growable === void 0 ? true : opt$.growable; | |
| 1936 return new core.List.from(this, {growable: growable}); | |
| 1937 } | |
| 1938 toSet() { | |
| 1939 return new core.Set.from(this); | |
| 1940 } | |
| 1941 get length() { | |
| 1942 dart.assert(!dart.is(this, _internal.EfficientLength)); | |
| 1943 let count = 0; | |
| 1944 let it = this.iterator; | |
| 1945 while (it.moveNext()) { | |
| 1946 count++; | |
| 1947 } | |
| 1948 return count; | |
| 1949 } | |
| 1950 get isEmpty() { | |
| 1951 return !dart.notNull(this.iterator.moveNext()); | |
| 1952 } | |
| 1953 get isNotEmpty() { | |
| 1954 return !dart.notNull(this.isEmpty); | |
| 1955 } | |
| 1956 take(n) { | |
| 1957 return new _internal.TakeIterable(this, n); | |
| 1958 } | |
| 1959 takeWhile(test) { | |
| 1960 return new _internal.TakeWhileIterable(this, test); | |
| 1961 } | |
| 1962 skip(n) { | |
| 1963 return new _internal.SkipIterable(this, n); | |
| 1964 } | |
| 1965 skipWhile(test) { | |
| 1966 return new _internal.SkipWhileIterable(this, test); | |
| 1967 } | |
| 1968 get first() { | |
| 1969 let it = this.iterator; | |
| 1970 if (!dart.notNull(it.moveNext())) { | |
| 1971 throw _internal.IterableElementError.noElement(); | |
| 1972 } | |
| 1973 return dart.as(it.current, E); | |
| 1974 } | |
| 1975 get last() { | |
| 1976 let it = this.iterator; | |
| 1977 if (!dart.notNull(it.moveNext())) { | |
| 1978 throw _internal.IterableElementError.noElement(); | |
| 1979 } | |
| 1980 let result = null; | |
| 1981 do { | |
| 1982 result = dart.as(it.current, E); | |
| 1983 } while (it.moveNext()); | |
| 1984 return result; | |
| 1985 } | |
| 1986 get single() { | |
| 1987 let it = this.iterator; | |
| 1988 if (!dart.notNull(it.moveNext())) | |
| 1989 throw _internal.IterableElementError.noElement(); | |
| 1990 let result = dart.as(it.current, E); | |
| 1991 if (it.moveNext()) | |
| 1992 throw _internal.IterableElementError.tooMany(); | |
| 1993 return result; | |
| 1994 } | |
| 1995 firstWhere(test, opt$) { | |
| 1996 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 1997 for (let element of this) { | |
| 1998 if (test(element)) | |
| 1999 return element; | |
| 2000 } | |
| 2001 if (orElse !== null) | |
| 2002 return orElse(); | |
| 2003 throw _internal.IterableElementError.noElement(); | |
| 2004 } | |
| 2005 lastWhere(test, opt$) { | |
| 2006 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 2007 let result = dart.as(null, E); | |
| 2008 let foundMatching = false; | |
| 2009 for (let element of this) { | |
| 2010 if (test(element)) { | |
| 2011 result = element; | |
| 2012 foundMatching = true; | |
| 2013 } | |
| 2014 } | |
| 2015 if (foundMatching) | |
| 2016 return result; | |
| 2017 if (orElse !== null) | |
| 2018 return orElse(); | |
| 2019 throw _internal.IterableElementError.noElement(); | |
| 2020 } | |
| 2021 singleWhere(test) { | |
| 2022 let result = dart.as(null, E); | |
| 2023 let foundMatching = false; | |
| 2024 for (let element of this) { | |
| 2025 if (test(element)) { | |
| 2026 if (foundMatching) { | |
| 2027 throw _internal.IterableElementError.tooMany(); | |
| 2028 } | |
| 2029 result = element; | |
| 2030 foundMatching = true; | |
| 2031 } | |
| 2032 } | |
| 2033 if (foundMatching) | |
| 2034 return result; | |
| 2035 throw _internal.IterableElementError.noElement(); | |
| 2036 } | |
| 2037 elementAt(index) { | |
| 2038 if (!(typeof index == number)) | |
| 2039 throw new core.ArgumentError.notNull("index"); | |
| 2040 core.RangeError.checkNotNegative(index, "index"); | |
| 2041 let elementIndex = 0; | |
| 2042 for (let element of this) { | |
| 2043 if (index === elementIndex) | |
| 2044 return element; | |
| 2045 elementIndex++; | |
| 2046 } | |
| 2047 throw new core.RangeError.index(index, this, "index", null, elementIndex
); | |
| 2048 } | |
| 2049 toString() { | |
| 2050 return iterableToShortString(this, '(', ')'); | |
| 2051 } | |
| 2052 static iterableToShortString(iterable, leftDelimiter, rightDelimiter) { | |
| 2053 if (leftDelimiter === void 0) | |
| 2054 leftDelimiter = '('; | |
| 2055 if (rightDelimiter === void 0) | |
| 2056 rightDelimiter = ')'; | |
| 2057 if (_isToStringVisiting(iterable)) { | |
| 2058 if (dart.notNull(dart.equals(leftDelimiter, "(")) && dart.notNull(dart
.equals(rightDelimiter, ")"))) { | |
| 2059 return "(...)"; | |
| 2060 } | |
| 2061 return `${leftDelimiter}...${rightDelimiter}`; | |
| 2062 } | |
| 2063 let parts = new List.from([]); | |
| 2064 _toStringVisiting.add(iterable); | |
| 2065 try { | |
| 2066 _iterablePartsToStrings(iterable, parts); | |
| 2067 } finally { | |
| 2068 dart.assert(core.identical(_toStringVisiting.last, iterable)); | |
| 2069 _toStringVisiting.removeLast(); | |
| 2070 } | |
| 2071 return ((_) => { | |
| 2072 _.writeAll(parts, ", "); | |
| 2073 _.write(rightDelimiter); | |
| 2074 return _; | |
| 2075 }).bind(this)(new core.StringBuffer(leftDelimiter)).toString(); | |
| 2076 } | |
| 2077 static iterableToFullString(iterable, leftDelimiter, rightDelimiter) { | |
| 2078 if (leftDelimiter === void 0) | |
| 2079 leftDelimiter = '('; | |
| 2080 if (rightDelimiter === void 0) | |
| 2081 rightDelimiter = ')'; | |
| 2082 if (_isToStringVisiting(iterable)) { | |
| 2083 return `${leftDelimiter}...${rightDelimiter}`; | |
| 2084 } | |
| 2085 let buffer = new core.StringBuffer(leftDelimiter); | |
| 2086 _toStringVisiting.add(iterable); | |
| 2087 try { | |
| 2088 buffer.writeAll(iterable, ", "); | |
| 2089 } finally { | |
| 2090 dart.assert(core.identical(_toStringVisiting.last, iterable)); | |
| 2091 _toStringVisiting.removeLast(); | |
| 2092 } | |
| 2093 buffer.write(rightDelimiter); | |
| 2094 return buffer.toString(); | |
| 2095 } | |
| 2096 static _isToStringVisiting(o) { | |
| 2097 for (let i = 0; i < _toStringVisiting.length; i++) { | |
| 2098 if (core.identical(o, _toStringVisiting.get(i))) | |
| 2099 return true; | |
| 2100 } | |
| 2101 return false; | |
| 2102 } | |
| 2103 static _iterablePartsToStrings(iterable, parts) { | |
| 2104 let LENGTH_LIMIT = 80; | |
| 2105 let HEAD_COUNT = 3; | |
| 2106 let TAIL_COUNT = 2; | |
| 2107 let MAX_COUNT = 100; | |
| 2108 let OVERHEAD = 2; | |
| 2109 let ELLIPSIS_SIZE = 3; | |
| 2110 let length = 0; | |
| 2111 let count = 0; | |
| 2112 let it = iterable.iterator; | |
| 2113 while (dart.notNull(length < LENGTH_LIMIT) || dart.notNull(count < HEAD_
COUNT)) { | |
| 2114 if (!dart.notNull(it.moveNext())) | |
| 2115 return; | |
| 2116 let next = `${it.current}`; | |
| 2117 parts.add(next); | |
| 2118 length = next.length + OVERHEAD; | |
| 2119 count++; | |
| 2120 } | |
| 2121 let penultimateString = null; | |
| 2122 let ultimateString = null; | |
| 2123 let penultimate = null; | |
| 2124 let ultimate = null; | |
| 2125 if (!dart.notNull(it.moveNext())) { | |
| 2126 if (count <= HEAD_COUNT + TAIL_COUNT) | |
| 2127 return; | |
| 2128 ultimateString = dart.as(parts.removeLast(), core.String); | |
| 2129 penultimateString = dart.as(parts.removeLast(), core.String); | |
| 2130 } else { | |
| 2131 penultimate = it.current; | |
| 2132 count++; | |
| 2133 if (!dart.notNull(it.moveNext())) { | |
| 2134 if (count <= HEAD_COUNT + 1) { | |
| 2135 parts.add(`${penultimate}`); | |
| 2136 return; | |
| 2137 } | |
| 2138 ultimateString = `${penultimate}`; | |
| 2139 penultimateString = dart.as(parts.removeLast(), core.String); | |
| 2140 length = ultimateString.length + OVERHEAD; | |
| 2141 } else { | |
| 2142 ultimate = it.current; | |
| 2143 count++; | |
| 2144 dart.assert(count < MAX_COUNT); | |
| 2145 while (it.moveNext()) { | |
| 2146 penultimate = ultimate; | |
| 2147 ultimate = it.current; | |
| 2148 count++; | |
| 2149 if (count > MAX_COUNT) { | |
| 2150 while (dart.notNull(length > LENGTH_LIMIT - ELLIPSIS_SIZE - OVER
HEAD) && dart.notNull(count > HEAD_COUNT)) { | |
| 2151 length = dart.as(dart.dbinary(dart.dload(parts.removeLast(), '
length'), '+', OVERHEAD), core.int); | |
| 2152 count--; | |
| 2153 } | |
| 2154 parts.add("..."); | |
| 2155 return; | |
| 2156 } | |
| 2157 } | |
| 2158 penultimateString = `${penultimate}`; | |
| 2159 ultimateString = `${ultimate}`; | |
| 2160 length = ultimateString.length + penultimateString.length + 2 * OVER
HEAD; | |
| 2161 } | |
| 2162 } | |
| 2163 let elision = null; | |
| 2164 if (count > parts.length + TAIL_COUNT) { | |
| 2165 elision = "..."; | |
| 2166 length = ELLIPSIS_SIZE + OVERHEAD; | |
| 2167 } | |
| 2168 while (dart.notNull(length > LENGTH_LIMIT) && dart.notNull(parts.length
> HEAD_COUNT)) { | |
| 2169 length = dart.as(dart.dbinary(dart.dload(parts.removeLast(), 'length')
, '+', OVERHEAD), core.int); | |
| 2170 if (elision === null) { | |
| 2171 elision = "..."; | |
| 2172 length = ELLIPSIS_SIZE + OVERHEAD; | |
| 2173 } | |
| 2174 } | |
| 2175 if (elision !== null) { | |
| 2176 parts.add(elision); | |
| 2177 } | |
| 2178 parts.add(penultimateString); | |
| 2179 parts.add(ultimateString); | |
| 2180 } | |
| 2181 } | |
| 2182 dart.defineLazyProperties(IterableBase, { | |
| 2183 get _toStringVisiting() { | |
| 2184 return new List.from([]); | |
| 2185 } | |
| 2186 }); | |
| 2187 return IterableBase; | |
| 2188 }); | |
| 2189 let IterableBase = IterableBase$(dynamic); | |
| 2190 let HasNextIterator$ = dart.generic(function(E) { | |
| 2191 class HasNextIterator extends dart.Object { | |
| 2192 HasNextIterator(_iterator) { | |
| 2193 this._iterator = _iterator; | |
| 2194 this._state = _NOT_MOVED_YET; | |
| 2195 } | |
| 2196 get hasNext() { | |
| 2197 if (this._state === _NOT_MOVED_YET) | |
| 2198 this._move(); | |
| 2199 return this._state === _HAS_NEXT_AND_NEXT_IN_CURRENT; | |
| 2200 } | |
| 2201 next() { | |
| 2202 if (!dart.notNull(this.hasNext)) | |
| 2203 throw new core.StateError("No more elements"); | |
| 2204 dart.assert(this._state === _HAS_NEXT_AND_NEXT_IN_CURRENT); | |
| 2205 let result = dart.as(this._iterator.current, E); | |
| 2206 this._move(); | |
| 2207 return result; | |
| 2208 } | |
| 2209 _move() { | |
| 2210 if (this._iterator.moveNext()) { | |
| 2211 this._state = _HAS_NEXT_AND_NEXT_IN_CURRENT; | |
| 2212 } else { | |
| 2213 this._state = _NO_NEXT; | |
| 2214 } | |
| 2215 } | |
| 2216 } | |
| 2217 HasNextIterator._HAS_NEXT_AND_NEXT_IN_CURRENT = 0; | |
| 2218 HasNextIterator._NO_NEXT = 1; | |
| 2219 HasNextIterator._NOT_MOVED_YET = 2; | |
| 2220 return HasNextIterator; | |
| 2221 }); | |
| 2222 let HasNextIterator = HasNextIterator$(dynamic); | |
| 2223 let LinkedHashMap$ = dart.generic(function(K, V) { | |
| 2224 class LinkedHashMap extends dart.Object { | |
| 2225 LinkedHashMap(opt$) { | |
| 2226 let equals = opt$.equals === void 0 ? null : opt$.equals; | |
| 2227 let hashCode = opt$.hashCode === void 0 ? null : opt$.hashCode; | |
| 2228 let isValidKey = opt$.isValidKey === void 0 ? null : opt$.isValidKey; | |
| 2229 if (isValidKey === null) { | |
| 2230 if (hashCode === null) { | |
| 2231 if (equals === null) { | |
| 2232 return new _LinkedHashMap(); | |
| 2233 } | |
| 2234 hashCode = _defaultHashCode; | |
| 2235 } else { | |
| 2236 if (dart.notNull(core.identical(core.identityHashCode, hashCode)) &&
dart.notNull(core.identical(core.identical, equals))) { | |
| 2237 return new _LinkedIdentityHashMap(); | |
| 2238 } | |
| 2239 if (equals === null) { | |
| 2240 equals = _defaultEquals; | |
| 2241 } | |
| 2242 } | |
| 2243 } else { | |
| 2244 if (hashCode === null) { | |
| 2245 hashCode = _defaultHashCode; | |
| 2246 } | |
| 2247 if (equals === null) { | |
| 2248 equals = _defaultEquals; | |
| 2249 } | |
| 2250 } | |
| 2251 return new _LinkedCustomHashMap(equals, hashCode, isValidKey); | |
| 2252 } | |
| 2253 LinkedHashMap$identity() { | |
| 2254 return new _LinkedIdentityHashMap(); | |
| 2255 } | |
| 2256 LinkedHashMap$from(other) { | |
| 2257 let result = new LinkedHashMap(); | |
| 2258 other.forEach((k, v) => { | |
| 2259 result.set(k, dart.as(v, V)); | |
| 2260 }); | |
| 2261 return result; | |
| 2262 } | |
| 2263 LinkedHashMap$fromIterable(iterable, opt$) { | |
| 2264 let key = opt$.key === void 0 ? null : opt$.key; | |
| 2265 let value = opt$.value === void 0 ? null : opt$.value; | |
| 2266 let map = new LinkedHashMap(); | |
| 2267 Maps._fillMapWithMappedIterable(map, iterable, key, value); | |
| 2268 return map; | |
| 2269 } | |
| 2270 LinkedHashMap$fromIterables(keys, values) { | |
| 2271 let map = new LinkedHashMap(); | |
| 2272 Maps._fillMapWithIterables(map, keys, values); | |
| 2273 return map; | |
| 2274 } | |
| 2275 LinkedHashMap$_literal(keyValuePairs) { | |
| 2276 return dart.as(_js_helper.fillLiteralMap(keyValuePairs, new _LinkedHashM
ap()), LinkedHashMap$(K, V)); | |
| 2277 } | |
| 2278 LinkedHashMap$_empty() { | |
| 2279 return new _LinkedHashMap(); | |
| 2280 } | |
| 2281 } | |
| 2282 dart.defineNamedConstructor(LinkedHashMap, 'identity'); | |
| 2283 dart.defineNamedConstructor(LinkedHashMap, 'from'); | |
| 2284 dart.defineNamedConstructor(LinkedHashMap, 'fromIterable'); | |
| 2285 dart.defineNamedConstructor(LinkedHashMap, 'fromIterables'); | |
| 2286 dart.defineNamedConstructor(LinkedHashMap, '_literal'); | |
| 2287 dart.defineNamedConstructor(LinkedHashMap, '_empty'); | |
| 2288 return LinkedHashMap; | |
| 2289 }); | |
| 2290 let LinkedHashMap = LinkedHashMap$(dynamic, dynamic); | |
| 2291 let LinkedHashSet$ = dart.generic(function(E) { | |
| 2292 class LinkedHashSet extends dart.Object { | |
| 2293 LinkedHashSet(opt$) { | |
| 2294 let equals = opt$.equals === void 0 ? null : opt$.equals; | |
| 2295 let hashCode = opt$.hashCode === void 0 ? null : opt$.hashCode; | |
| 2296 let isValidKey = opt$.isValidKey === void 0 ? null : opt$.isValidKey; | |
| 2297 if (isValidKey === null) { | |
| 2298 if (hashCode === null) { | |
| 2299 if (equals === null) { | |
| 2300 return new _LinkedHashSet(); | |
| 2301 } | |
| 2302 hashCode = _defaultHashCode; | |
| 2303 } else { | |
| 2304 if (dart.notNull(core.identical(core.identityHashCode, hashCode)) &&
dart.notNull(core.identical(core.identical, equals))) { | |
| 2305 return new _LinkedIdentityHashSet(); | |
| 2306 } | |
| 2307 if (equals === null) { | |
| 2308 equals = _defaultEquals; | |
| 2309 } | |
| 2310 } | |
| 2311 } else { | |
| 2312 if (hashCode === null) { | |
| 2313 hashCode = _defaultHashCode; | |
| 2314 } | |
| 2315 if (equals === null) { | |
| 2316 equals = _defaultEquals; | |
| 2317 } | |
| 2318 } | |
| 2319 return new _LinkedCustomHashSet(equals, hashCode, isValidKey); | |
| 2320 } | |
| 2321 LinkedHashSet$identity() { | |
| 2322 return new _LinkedIdentityHashSet(); | |
| 2323 } | |
| 2324 LinkedHashSet$from(elements) { | |
| 2325 let result = new LinkedHashSet(); | |
| 2326 for (let element of elements) { | |
| 2327 result.add(element); | |
| 2328 } | |
| 2329 return result; | |
| 2330 } | |
| 2331 } | |
| 2332 dart.defineNamedConstructor(LinkedHashSet, 'identity'); | |
| 2333 dart.defineNamedConstructor(LinkedHashSet, 'from'); | |
| 2334 return LinkedHashSet; | |
| 2335 }); | |
| 2336 let LinkedHashSet = LinkedHashSet$(dynamic); | |
| 2337 let LinkedList$ = dart.generic(function(E) { | |
| 2338 class LinkedList extends IterableBase$(E) { | |
| 2339 LinkedList() { | |
| 2340 this._modificationCount = 0; | |
| 2341 this._length = 0; | |
| 2342 this._next = null; | |
| 2343 this._previous = null; | |
| 2344 super.IterableBase(); | |
| 2345 this._next = this._previous = this; | |
| 2346 } | |
| 2347 addFirst(entry) { | |
| 2348 this._insertAfter(this, entry); | |
| 2349 } | |
| 2350 add(entry) { | |
| 2351 this._insertAfter(this._previous, entry); | |
| 2352 } | |
| 2353 addAll(entries) { | |
| 2354 entries.forEach(((entry) => this._insertAfter(this._previous, dart.as(en
try, E))).bind(this)); | |
| 2355 } | |
| 2356 remove(entry) { | |
| 2357 if (!dart.equals(entry._list, this)) | |
| 2358 return false; | |
| 2359 this._unlink(entry); | |
| 2360 return true; | |
| 2361 } | |
| 2362 get iterator() { | |
| 2363 return new _LinkedListIterator(this); | |
| 2364 } | |
| 2365 get length() { | |
| 2366 return this._length; | |
| 2367 } | |
| 2368 clear() { | |
| 2369 this._modificationCount++; | |
| 2370 let next = this._next; | |
| 2371 while (!dart.notNull(core.identical(next, this))) { | |
| 2372 let entry = dart.as(next, E); | |
| 2373 next = entry._next; | |
| 2374 entry._next = entry._previous = entry._list = null; | |
| 2375 } | |
| 2376 this._next = this._previous = this; | |
| 2377 this._length = 0; | |
| 2378 } | |
| 2379 get first() { | |
| 2380 if (core.identical(this._next, this)) { | |
| 2381 throw new core.StateError('No such element'); | |
| 2382 } | |
| 2383 return dart.as(this._next, E); | |
| 2384 } | |
| 2385 get last() { | |
| 2386 if (core.identical(this._previous, this)) { | |
| 2387 throw new core.StateError('No such element'); | |
| 2388 } | |
| 2389 return dart.as(this._previous, E); | |
| 2390 } | |
| 2391 get single() { | |
| 2392 if (core.identical(this._previous, this)) { | |
| 2393 throw new core.StateError('No such element'); | |
| 2394 } | |
| 2395 if (!dart.notNull(core.identical(this._previous, this._next))) { | |
| 2396 throw new core.StateError('Too many elements'); | |
| 2397 } | |
| 2398 return dart.as(this._next, E); | |
| 2399 } | |
| 2400 forEach(action) { | |
| 2401 let modificationCount = this._modificationCount; | |
| 2402 let current = this._next; | |
| 2403 while (!dart.notNull(core.identical(current, this))) { | |
| 2404 action(dart.as(current, E)); | |
| 2405 if (modificationCount !== this._modificationCount) { | |
| 2406 throw new core.ConcurrentModificationError(this); | |
| 2407 } | |
| 2408 current = current._next; | |
| 2409 } | |
| 2410 } | |
| 2411 get isEmpty() { | |
| 2412 return this._length === 0; | |
| 2413 } | |
| 2414 _insertAfter(entry, newEntry) { | |
| 2415 if (newEntry.list !== null) { | |
| 2416 throw new core.StateError('LinkedListEntry is already in a LinkedList'
); | |
| 2417 } | |
| 2418 this._modificationCount++; | |
| 2419 newEntry._list = this; | |
| 2420 let predecessor = entry; | |
| 2421 let successor = entry._next; | |
| 2422 successor._previous = newEntry; | |
| 2423 newEntry._previous = predecessor; | |
| 2424 newEntry._next = successor; | |
| 2425 predecessor._next = newEntry; | |
| 2426 this._length++; | |
| 2427 } | |
| 2428 _unlink(entry) { | |
| 2429 this._modificationCount++; | |
| 2430 entry._next._previous = entry._previous; | |
| 2431 entry._previous._next = entry._next; | |
| 2432 this._length--; | |
| 2433 entry._list = entry._next = entry._previous = null; | |
| 2434 } | |
| 2435 } | |
| 2436 return LinkedList; | |
| 2437 }); | |
| 2438 let LinkedList = LinkedList$(dynamic); | |
| 2439 let _LinkedListIterator$ = dart.generic(function(E) { | |
| 2440 class _LinkedListIterator extends dart.Object { | |
| 2441 _LinkedListIterator(list) { | |
| 2442 this._list = list; | |
| 2443 this._modificationCount = list._modificationCount; | |
| 2444 this._next = list._next; | |
| 2445 this._current = null; | |
| 2446 } | |
| 2447 get current() { | |
| 2448 return this._current; | |
| 2449 } | |
| 2450 moveNext() { | |
| 2451 if (core.identical(this._next, this._list)) { | |
| 2452 this._current = null; | |
| 2453 return false; | |
| 2454 } | |
| 2455 if (this._modificationCount !== this._list._modificationCount) { | |
| 2456 throw new core.ConcurrentModificationError(this); | |
| 2457 } | |
| 2458 this._current = dart.as(this._next, E); | |
| 2459 this._next = this._next._next; | |
| 2460 return true; | |
| 2461 } | |
| 2462 } | |
| 2463 return _LinkedListIterator; | |
| 2464 }); | |
| 2465 let _LinkedListIterator = _LinkedListIterator$(dynamic); | |
| 2466 class _LinkedListLink extends dart.Object { | |
| 2467 _LinkedListLink() { | |
| 2468 this._next = null; | |
| 2469 this._previous = null; | |
| 2470 } | |
| 2471 } | |
| 2472 let LinkedListEntry$ = dart.generic(function(E) { | |
| 2473 class LinkedListEntry extends dart.Object { | |
| 2474 LinkedListEntry() { | |
| 2475 this._list = null; | |
| 2476 this._next = null; | |
| 2477 this._previous = null; | |
| 2478 } | |
| 2479 get list() { | |
| 2480 return this._list; | |
| 2481 } | |
| 2482 unlink() { | |
| 2483 this._list._unlink(this); | |
| 2484 } | |
| 2485 get next() { | |
| 2486 if (core.identical(this._next, this._list)) | |
| 2487 return null; | |
| 2488 let result = dart.as(this._next, E); | |
| 2489 return result; | |
| 2490 } | |
| 2491 get previous() { | |
| 2492 if (core.identical(this._previous, this._list)) | |
| 2493 return null; | |
| 2494 return dart.as(this._previous, E); | |
| 2495 } | |
| 2496 insertAfter(entry) { | |
| 2497 this._list._insertAfter(this, entry); | |
| 2498 } | |
| 2499 insertBefore(entry) { | |
| 2500 this._list._insertAfter(this._previous, entry); | |
| 2501 } | |
| 2502 } | |
| 2503 return LinkedListEntry; | |
| 2504 }); | |
| 2505 let LinkedListEntry = LinkedListEntry$(dynamic); | |
| 2506 let ListBase$ = dart.generic(function(E) { | |
| 2507 class ListBase extends dart.mixin(core.Object, ListMixin$(E)) { | |
| 2508 static listToString(list) { | |
| 2509 return IterableBase.iterableToFullString(list, '[', ']'); | |
| 2510 } | |
| 2511 } | |
| 2512 return ListBase; | |
| 2513 }); | |
| 2514 let ListBase = ListBase$(dynamic); | |
| 2515 let ListMixin$ = dart.generic(function(E) { | |
| 2516 class ListMixin extends dart.Object { | |
| 2517 get iterator() { | |
| 2518 return new _internal.ListIterator(this); | |
| 2519 } | |
| 2520 elementAt(index) { | |
| 2521 return this.get(index); | |
| 2522 } | |
| 2523 forEach(action) { | |
| 2524 let length = this.length; | |
| 2525 for (let i = 0; i < length; i++) { | |
| 2526 action(this.get(i)); | |
| 2527 if (length !== this.length) { | |
| 2528 throw new core.ConcurrentModificationError(this); | |
| 2529 } | |
| 2530 } | |
| 2531 } | |
| 2532 get isEmpty() { | |
| 2533 return this.length === 0; | |
| 2534 } | |
| 2535 get isNotEmpty() { | |
| 2536 return !dart.notNull(this.isEmpty); | |
| 2537 } | |
| 2538 get first() { | |
| 2539 if (this.length === 0) | |
| 2540 throw _internal.IterableElementError.noElement(); | |
| 2541 return this.get(0); | |
| 2542 } | |
| 2543 get last() { | |
| 2544 if (this.length === 0) | |
| 2545 throw _internal.IterableElementError.noElement(); | |
| 2546 return this.get(this.length - 1); | |
| 2547 } | |
| 2548 get single() { | |
| 2549 if (this.length === 0) | |
| 2550 throw _internal.IterableElementError.noElement(); | |
| 2551 if (this.length > 1) | |
| 2552 throw _internal.IterableElementError.tooMany(); | |
| 2553 return this.get(0); | |
| 2554 } | |
| 2555 contains(element) { | |
| 2556 let length = this.length; | |
| 2557 for (let i = 0; i < this.length; i++) { | |
| 2558 if (dart.equals(this.get(i), element)) | |
| 2559 return true; | |
| 2560 if (length !== this.length) { | |
| 2561 throw new core.ConcurrentModificationError(this); | |
| 2562 } | |
| 2563 } | |
| 2564 return false; | |
| 2565 } | |
| 2566 every(test) { | |
| 2567 let length = this.length; | |
| 2568 for (let i = 0; i < length; i++) { | |
| 2569 if (!dart.notNull(test(this.get(i)))) | |
| 2570 return false; | |
| 2571 if (length !== this.length) { | |
| 2572 throw new core.ConcurrentModificationError(this); | |
| 2573 } | |
| 2574 } | |
| 2575 return true; | |
| 2576 } | |
| 2577 any(test) { | |
| 2578 let length = this.length; | |
| 2579 for (let i = 0; i < length; i++) { | |
| 2580 if (test(this.get(i))) | |
| 2581 return true; | |
| 2582 if (length !== this.length) { | |
| 2583 throw new core.ConcurrentModificationError(this); | |
| 2584 } | |
| 2585 } | |
| 2586 return false; | |
| 2587 } | |
| 2588 firstWhere(test, opt$) { | |
| 2589 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 2590 let length = this.length; | |
| 2591 for (let i = 0; i < length; i++) { | |
| 2592 let element = this.get(i); | |
| 2593 if (test(element)) | |
| 2594 return element; | |
| 2595 if (length !== this.length) { | |
| 2596 throw new core.ConcurrentModificationError(this); | |
| 2597 } | |
| 2598 } | |
| 2599 if (orElse !== null) | |
| 2600 return orElse(); | |
| 2601 throw _internal.IterableElementError.noElement(); | |
| 2602 } | |
| 2603 lastWhere(test, opt$) { | |
| 2604 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 2605 let length = this.length; | |
| 2606 for (let i = length - 1; i >= 0; i--) { | |
| 2607 let element = this.get(i); | |
| 2608 if (test(element)) | |
| 2609 return element; | |
| 2610 if (length !== this.length) { | |
| 2611 throw new core.ConcurrentModificationError(this); | |
| 2612 } | |
| 2613 } | |
| 2614 if (orElse !== null) | |
| 2615 return orElse(); | |
| 2616 throw _internal.IterableElementError.noElement(); | |
| 2617 } | |
| 2618 singleWhere(test) { | |
| 2619 let length = this.length; | |
| 2620 let match = dart.as(null, E); | |
| 2621 let matchFound = false; | |
| 2622 for (let i = 0; i < length; i++) { | |
| 2623 let element = this.get(i); | |
| 2624 if (test(element)) { | |
| 2625 if (matchFound) { | |
| 2626 throw _internal.IterableElementError.tooMany(); | |
| 2627 } | |
| 2628 matchFound = true; | |
| 2629 match = element; | |
| 2630 } | |
| 2631 if (length !== this.length) { | |
| 2632 throw new core.ConcurrentModificationError(this); | |
| 2633 } | |
| 2634 } | |
| 2635 if (matchFound) | |
| 2636 return match; | |
| 2637 throw _internal.IterableElementError.noElement(); | |
| 2638 } | |
| 2639 join(separator) { | |
| 2640 if (separator === void 0) | |
| 2641 separator = ""; | |
| 2642 if (this.length === 0) | |
| 2643 return ""; | |
| 2644 let buffer = new core.StringBuffer(); | |
| 2645 buffer.writeAll(this, separator); | |
| 2646 return buffer.toString(); | |
| 2647 } | |
| 2648 where(test) { | |
| 2649 return new _internal.WhereIterable(this, test); | |
| 2650 } | |
| 2651 map(f) { | |
| 2652 return new _internal.MappedListIterable(this, dart.as(f, dart.throw_("Un
implemented type (dynamic) → dynamic"))); | |
| 2653 } | |
| 2654 expand(f) { | |
| 2655 return new _internal.ExpandIterable(this, f); | |
| 2656 } | |
| 2657 reduce(combine) { | |
| 2658 let length = this.length; | |
| 2659 if (length === 0) | |
| 2660 throw _internal.IterableElementError.noElement(); | |
| 2661 let value = this.get(0); | |
| 2662 for (let i = 1; i < length; i++) { | |
| 2663 value = combine(value, this.get(i)); | |
| 2664 if (length !== this.length) { | |
| 2665 throw new core.ConcurrentModificationError(this); | |
| 2666 } | |
| 2667 } | |
| 2668 return value; | |
| 2669 } | |
| 2670 fold(initialValue, combine) { | |
| 2671 let value = initialValue; | |
| 2672 let length = this.length; | |
| 2673 for (let i = 0; i < length; i++) { | |
| 2674 value = combine(value, this.get(i)); | |
| 2675 if (length !== this.length) { | |
| 2676 throw new core.ConcurrentModificationError(this); | |
| 2677 } | |
| 2678 } | |
| 2679 return value; | |
| 2680 } | |
| 2681 skip(count) { | |
| 2682 return new _internal.SubListIterable(this, count, dart.as(null, core.int
)); | |
| 2683 } | |
| 2684 skipWhile(test) { | |
| 2685 return new _internal.SkipWhileIterable(this, test); | |
| 2686 } | |
| 2687 take(count) { | |
| 2688 return new _internal.SubListIterable(this, 0, count); | |
| 2689 } | |
| 2690 takeWhile(test) { | |
| 2691 return new _internal.TakeWhileIterable(this, test); | |
| 2692 } | |
| 2693 toList(opt$) { | |
| 2694 let growable = opt$.growable === void 0 ? true : opt$.growable; | |
| 2695 let result = null; | |
| 2696 if (growable) { | |
| 2697 result = ((_) => { | |
| 2698 _.length = this.length; | |
| 2699 return _; | |
| 2700 }).bind(this)(new core.List()); | |
| 2701 } else { | |
| 2702 result = new core.List(this.length); | |
| 2703 } | |
| 2704 for (let i = 0; i < this.length; i++) { | |
| 2705 result.set(i, this.get(i)); | |
| 2706 } | |
| 2707 return result; | |
| 2708 } | |
| 2709 toSet() { | |
| 2710 let result = new core.Set(); | |
| 2711 for (let i = 0; i < this.length; i++) { | |
| 2712 result.add(this.get(i)); | |
| 2713 } | |
| 2714 return result; | |
| 2715 } | |
| 2716 add(element) { | |
| 2717 this.set(this.length++, element); | |
| 2718 } | |
| 2719 addAll(iterable) { | |
| 2720 for (let element of iterable) { | |
| 2721 this.set(this.length++, element); | |
| 2722 } | |
| 2723 } | |
| 2724 remove(element) { | |
| 2725 for (let i = 0; i < this.length; i++) { | |
| 2726 if (dart.equals(this.get(i), element)) { | |
| 2727 this.setRange(i, this.length - 1, this, i + 1); | |
| 2728 this.length = 1; | |
| 2729 return true; | |
| 2730 } | |
| 2731 } | |
| 2732 return false; | |
| 2733 } | |
| 2734 removeWhere(test) { | |
| 2735 _filter(this, dart.as(test, dart.throw_("Unimplemented type (dynamic) →
bool")), false); | |
| 2736 } | |
| 2737 retainWhere(test) { | |
| 2738 _filter(this, dart.as(test, dart.throw_("Unimplemented type (dynamic) →
bool")), true); | |
| 2739 } | |
| 2740 static _filter(source, test, retainMatching) { | |
| 2741 let retained = new List.from([]); | |
| 2742 let length = source.length; | |
| 2743 for (let i = 0; i < length; i++) { | |
| 2744 let element = source.get(i); | |
| 2745 if (test(element) === retainMatching) { | |
| 2746 retained.add(element); | |
| 2747 } | |
| 2748 if (length !== source.length) { | |
| 2749 throw new core.ConcurrentModificationError(source); | |
| 2750 } | |
| 2751 } | |
| 2752 if (retained.length !== source.length) { | |
| 2753 source.setRange(0, retained.length, retained); | |
| 2754 source.length = retained.length; | |
| 2755 } | |
| 2756 } | |
| 2757 clear() { | |
| 2758 this.length = 0; | |
| 2759 } | |
| 2760 removeLast() { | |
| 2761 if (this.length === 0) { | |
| 2762 throw _internal.IterableElementError.noElement(); | |
| 2763 } | |
| 2764 let result = this.get(this.length - 1); | |
| 2765 this.length--; | |
| 2766 return result; | |
| 2767 } | |
| 2768 sort(compare) { | |
| 2769 if (compare === void 0) | |
| 2770 compare = null; | |
| 2771 if (compare === null) { | |
| 2772 let defaultCompare = core.Comparable.compare; | |
| 2773 compare = defaultCompare; | |
| 2774 } | |
| 2775 _internal.Sort.sort(this, dart.as(compare, dart.throw_("Unimplemented ty
pe (dynamic, dynamic) → int"))); | |
| 2776 } | |
| 2777 shuffle(random) { | |
| 2778 if (random === void 0) | |
| 2779 random = null; | |
| 2780 if (random === null) | |
| 2781 random = new math.Random(); | |
| 2782 let length = this.length; | |
| 2783 while (length > 1) { | |
| 2784 let pos = random.nextInt(length); | |
| 2785 length = 1; | |
| 2786 let tmp = this.get(length); | |
| 2787 this.set(length, this.get(pos)); | |
| 2788 this.set(pos, tmp); | |
| 2789 } | |
| 2790 } | |
| 2791 asMap() { | |
| 2792 return new _internal.ListMapView(this); | |
| 2793 } | |
| 2794 sublist(start, end) { | |
| 2795 if (end === void 0) | |
| 2796 end = null; | |
| 2797 let listLength = this.length; | |
| 2798 if (end === null) | |
| 2799 end = listLength; | |
| 2800 core.RangeError.checkValidRange(start, end, listLength); | |
| 2801 let length = end - start; | |
| 2802 let result = new core.List(); | |
| 2803 result.length = length; | |
| 2804 for (let i = 0; i < length; i++) { | |
| 2805 result.set(i, this.get(start + i)); | |
| 2806 } | |
| 2807 return result; | |
| 2808 } | |
| 2809 getRange(start, end) { | |
| 2810 core.RangeError.checkValidRange(start, end, this.length); | |
| 2811 return new _internal.SubListIterable(this, start, end); | |
| 2812 } | |
| 2813 removeRange(start, end) { | |
| 2814 core.RangeError.checkValidRange(start, end, this.length); | |
| 2815 let length = end - start; | |
| 2816 this.setRange(start, this.length - length, this, end); | |
| 2817 this.length = length; | |
| 2818 } | |
| 2819 fillRange(start, end, fill) { | |
| 2820 if (fill === void 0) | |
| 2821 fill = null; | |
| 2822 core.RangeError.checkValidRange(start, end, this.length); | |
| 2823 for (let i = start; i < end; i++) { | |
| 2824 this.set(i, fill); | |
| 2825 } | |
| 2826 } | |
| 2827 setRange(start, end, iterable, skipCount) { | |
| 2828 if (skipCount === void 0) | |
| 2829 skipCount = 0; | |
| 2830 core.RangeError.checkValidRange(start, end, this.length); | |
| 2831 let length = end - start; | |
| 2832 if (length === 0) | |
| 2833 return; | |
| 2834 core.RangeError.checkNotNegative(skipCount, "skipCount"); | |
| 2835 let otherList = null; | |
| 2836 let otherStart = null; | |
| 2837 if (dart.is(iterable, core.List)) { | |
| 2838 otherList = dart.as(iterable, core.List); | |
| 2839 otherStart = skipCount; | |
| 2840 } else { | |
| 2841 otherList = iterable.skip(skipCount).toList({growable: false}); | |
| 2842 otherStart = 0; | |
| 2843 } | |
| 2844 if (otherStart + length > otherList.length) { | |
| 2845 throw _internal.IterableElementError.tooFew(); | |
| 2846 } | |
| 2847 if (otherStart < start) { | |
| 2848 for (let i = length - 1; i >= 0; i--) { | |
| 2849 this.set(start + i, dart.as(otherList.get(otherStart + i), E)); | |
| 2850 } | |
| 2851 } else { | |
| 2852 for (let i = 0; i < length; i++) { | |
| 2853 this.set(start + i, dart.as(otherList.get(otherStart + i), E)); | |
| 2854 } | |
| 2855 } | |
| 2856 } | |
| 2857 replaceRange(start, end, newContents) { | |
| 2858 core.RangeError.checkValidRange(start, end, this.length); | |
| 2859 if (!dart.is(newContents, _internal.EfficientLength)) { | |
| 2860 newContents = newContents.toList(); | |
| 2861 } | |
| 2862 let removeLength = end - start; | |
| 2863 let insertLength = newContents.length; | |
| 2864 if (removeLength >= insertLength) { | |
| 2865 let delta = removeLength - insertLength; | |
| 2866 let insertEnd = start + insertLength; | |
| 2867 let newLength = this.length - delta; | |
| 2868 this.setRange(start, insertEnd, newContents); | |
| 2869 if (delta !== 0) { | |
| 2870 this.setRange(insertEnd, newLength, this, end); | |
| 2871 this.length = newLength; | |
| 2872 } | |
| 2873 } else { | |
| 2874 let delta = insertLength - removeLength; | |
| 2875 let newLength = this.length + delta; | |
| 2876 let insertEnd = start + insertLength; | |
| 2877 this.length = newLength; | |
| 2878 this.setRange(insertEnd, newLength, this, end); | |
| 2879 this.setRange(start, insertEnd, newContents); | |
| 2880 } | |
| 2881 } | |
| 2882 indexOf(element, startIndex) { | |
| 2883 if (startIndex === void 0) | |
| 2884 startIndex = 0; | |
| 2885 if (startIndex >= this.length) { | |
| 2886 return -1; | |
| 2887 } | |
| 2888 if (startIndex < 0) { | |
| 2889 startIndex = 0; | |
| 2890 } | |
| 2891 for (let i = startIndex; i < this.length; i++) { | |
| 2892 if (dart.equals(this.get(i), element)) { | |
| 2893 return i; | |
| 2894 } | |
| 2895 } | |
| 2896 return -1; | |
| 2897 } | |
| 2898 lastIndexOf(element, startIndex) { | |
| 2899 if (startIndex === void 0) | |
| 2900 startIndex = null; | |
| 2901 if (startIndex === null) { | |
| 2902 startIndex = this.length - 1; | |
| 2903 } else { | |
| 2904 if (startIndex < 0) { | |
| 2905 return -1; | |
| 2906 } | |
| 2907 if (startIndex >= this.length) { | |
| 2908 startIndex = this.length - 1; | |
| 2909 } | |
| 2910 } | |
| 2911 for (let i = startIndex; i >= 0; i--) { | |
| 2912 if (dart.equals(this.get(i), element)) { | |
| 2913 return i; | |
| 2914 } | |
| 2915 } | |
| 2916 return -1; | |
| 2917 } | |
| 2918 insert(index, element) { | |
| 2919 core.RangeError.checkValueInInterval(index, 0, this.length, "index"); | |
| 2920 if (index === this.length) { | |
| 2921 this.add(element); | |
| 2922 return; | |
| 2923 } | |
| 2924 if (!(typeof index == number)) | |
| 2925 throw new core.ArgumentError(index); | |
| 2926 this.length++; | |
| 2927 this.setRange(index + 1, this.length, this, index); | |
| 2928 this.set(index, element); | |
| 2929 } | |
| 2930 removeAt(index) { | |
| 2931 let result = this.get(index); | |
| 2932 this.setRange(index, this.length - 1, this, index + 1); | |
| 2933 this.length--; | |
| 2934 return result; | |
| 2935 } | |
| 2936 insertAll(index, iterable) { | |
| 2937 core.RangeError.checkValueInInterval(index, 0, this.length, "index"); | |
| 2938 if (dart.is(iterable, _internal.EfficientLength)) { | |
| 2939 iterable = iterable.toList(); | |
| 2940 } | |
| 2941 let insertionLength = iterable.length; | |
| 2942 this.length = insertionLength; | |
| 2943 this.setRange(index + insertionLength, this.length, this, index); | |
| 2944 this.setAll(index, iterable); | |
| 2945 } | |
| 2946 setAll(index, iterable) { | |
| 2947 if (dart.is(iterable, core.List)) { | |
| 2948 this.setRange(index, index + iterable.length, iterable); | |
| 2949 } else { | |
| 2950 for (let element of iterable) { | |
| 2951 this.set(index++, element); | |
| 2952 } | |
| 2953 } | |
| 2954 } | |
| 2955 get reversed() { | |
| 2956 return new _internal.ReversedListIterable(this); | |
| 2957 } | |
| 2958 toString() { | |
| 2959 return IterableBase.iterableToFullString(this, '[', ']'); | |
| 2960 } | |
| 2961 } | |
| 2962 return ListMixin; | |
| 2963 }); | |
| 2964 let ListMixin = ListMixin$(dynamic); | |
| 2965 let MapBase$ = dart.generic(function(K, V) { | |
| 2966 class MapBase extends dart.mixin(MapMixin$(K, V)) { | |
| 2967 } | |
| 2968 return MapBase; | |
| 2969 }); | |
| 2970 let MapBase = MapBase$(dynamic, dynamic); | |
| 2971 let MapMixin$ = dart.generic(function(K, V) { | |
| 2972 class MapMixin extends dart.Object { | |
| 2973 forEach(action) { | |
| 2974 for (let key of this.keys) { | |
| 2975 action(key, this.get(key)); | |
| 2976 } | |
| 2977 } | |
| 2978 addAll(other) { | |
| 2979 for (let key of other.keys) { | |
| 2980 this.set(key, other.get(key)); | |
| 2981 } | |
| 2982 } | |
| 2983 containsValue(value) { | |
| 2984 for (let key of this.keys) { | |
| 2985 if (dart.equals(this.get(key), value)) | |
| 2986 return true; | |
| 2987 } | |
| 2988 return false; | |
| 2989 } | |
| 2990 putIfAbsent(key, ifAbsent) { | |
| 2991 if (this.keys.contains(key)) { | |
| 2992 return this.get(key); | |
| 2993 } | |
| 2994 return this.set(key, ifAbsent()); | |
| 2995 } | |
| 2996 containsKey(key) { | |
| 2997 return this.keys.contains(key); | |
| 2998 } | |
| 2999 get length() { | |
| 3000 return this.keys.length; | |
| 3001 } | |
| 3002 get isEmpty() { | |
| 3003 return this.keys.isEmpty; | |
| 3004 } | |
| 3005 get isNotEmpty() { | |
| 3006 return this.keys.isNotEmpty; | |
| 3007 } | |
| 3008 get values() { | |
| 3009 return new _MapBaseValueIterable(this); | |
| 3010 } | |
| 3011 toString() { | |
| 3012 return Maps.mapToString(this); | |
| 3013 } | |
| 3014 } | |
| 3015 return MapMixin; | |
| 3016 }); | |
| 3017 let MapMixin = MapMixin$(dynamic, dynamic); | |
| 3018 let UnmodifiableMapBase$ = dart.generic(function(K, V) { | |
| 3019 class UnmodifiableMapBase extends dart.mixin(_UnmodifiableMapMixin$(K, V)) { | |
| 3020 } | |
| 3021 return UnmodifiableMapBase; | |
| 3022 }); | |
| 3023 let UnmodifiableMapBase = UnmodifiableMapBase$(dynamic, dynamic); | |
| 3024 let _MapBaseValueIterable$ = dart.generic(function(V) { | |
| 3025 class _MapBaseValueIterable extends IterableBase$(V) { | |
| 3026 _MapBaseValueIterable(_map) { | |
| 3027 this._map = _map; | |
| 3028 super.IterableBase(); | |
| 3029 } | |
| 3030 get length() { | |
| 3031 return this._map.length; | |
| 3032 } | |
| 3033 get isEmpty() { | |
| 3034 return this._map.isEmpty; | |
| 3035 } | |
| 3036 get isNotEmpty() { | |
| 3037 return this._map.isNotEmpty; | |
| 3038 } | |
| 3039 get first() { | |
| 3040 return dart.as(this._map.get(this._map.keys.first), V); | |
| 3041 } | |
| 3042 get single() { | |
| 3043 return dart.as(this._map.get(this._map.keys.single), V); | |
| 3044 } | |
| 3045 get last() { | |
| 3046 return dart.as(this._map.get(this._map.keys.last), V); | |
| 3047 } | |
| 3048 get iterator() { | |
| 3049 return new _MapBaseValueIterator(this._map); | |
| 3050 } | |
| 3051 } | |
| 3052 return _MapBaseValueIterable; | |
| 3053 }); | |
| 3054 let _MapBaseValueIterable = _MapBaseValueIterable$(dynamic); | |
| 3055 let _MapBaseValueIterator$ = dart.generic(function(V) { | |
| 3056 class _MapBaseValueIterator extends dart.Object { | |
| 3057 _MapBaseValueIterator(map) { | |
| 3058 this._map = map; | |
| 3059 this._keys = map.keys.iterator; | |
| 3060 this._current = dart.as(null, V); | |
| 3061 } | |
| 3062 moveNext() { | |
| 3063 if (this._keys.moveNext()) { | |
| 3064 this._current = dart.as(this._map.get(this._keys.current), V); | |
| 3065 return true; | |
| 3066 } | |
| 3067 this._current = dart.as(null, V); | |
| 3068 return false; | |
| 3069 } | |
| 3070 get current() { | |
| 3071 return this._current; | |
| 3072 } | |
| 3073 } | |
| 3074 return _MapBaseValueIterator; | |
| 3075 }); | |
| 3076 let _MapBaseValueIterator = _MapBaseValueIterator$(dynamic); | |
| 3077 let _UnmodifiableMapMixin$ = dart.generic(function(K, V) { | |
| 3078 class _UnmodifiableMapMixin extends dart.Object { | |
| 3079 set(key, value) { | |
| 3080 throw new core.UnsupportedError("Cannot modify unmodifiable map"); | |
| 3081 } | |
| 3082 addAll(other) { | |
| 3083 throw new core.UnsupportedError("Cannot modify unmodifiable map"); | |
| 3084 } | |
| 3085 clear() { | |
| 3086 throw new core.UnsupportedError("Cannot modify unmodifiable map"); | |
| 3087 } | |
| 3088 remove(key) { | |
| 3089 throw new core.UnsupportedError("Cannot modify unmodifiable map"); | |
| 3090 } | |
| 3091 putIfAbsent(key, ifAbsent) { | |
| 3092 throw new core.UnsupportedError("Cannot modify unmodifiable map"); | |
| 3093 } | |
| 3094 } | |
| 3095 return _UnmodifiableMapMixin; | |
| 3096 }); | |
| 3097 let _UnmodifiableMapMixin = _UnmodifiableMapMixin$(dynamic, dynamic); | |
| 3098 let MapView$ = dart.generic(function(K, V) { | |
| 3099 class MapView extends dart.Object { | |
| 3100 MapView(map) { | |
| 3101 this._map = map; | |
| 3102 } | |
| 3103 get(key) { | |
| 3104 return this._map.get(key); | |
| 3105 } | |
| 3106 set(key, value) { | |
| 3107 this._map.set(key, value); | |
| 3108 } | |
| 3109 addAll(other) { | |
| 3110 this._map.addAll(other); | |
| 3111 } | |
| 3112 clear() { | |
| 3113 this._map.clear(); | |
| 3114 } | |
| 3115 putIfAbsent(key, ifAbsent) { | |
| 3116 return this._map.putIfAbsent(key, ifAbsent); | |
| 3117 } | |
| 3118 containsKey(key) { | |
| 3119 return this._map.containsKey(key); | |
| 3120 } | |
| 3121 containsValue(value) { | |
| 3122 return this._map.containsValue(value); | |
| 3123 } | |
| 3124 forEach(action) { | |
| 3125 this._map.forEach(action); | |
| 3126 } | |
| 3127 get isEmpty() { | |
| 3128 return this._map.isEmpty; | |
| 3129 } | |
| 3130 get isNotEmpty() { | |
| 3131 return this._map.isNotEmpty; | |
| 3132 } | |
| 3133 get length() { | |
| 3134 return this._map.length; | |
| 3135 } | |
| 3136 get keys() { | |
| 3137 return this._map.keys; | |
| 3138 } | |
| 3139 remove(key) { | |
| 3140 return this._map.remove(key); | |
| 3141 } | |
| 3142 toString() { | |
| 3143 return this._map.toString(); | |
| 3144 } | |
| 3145 get values() { | |
| 3146 return this._map.values; | |
| 3147 } | |
| 3148 } | |
| 3149 return MapView; | |
| 3150 }); | |
| 3151 let MapView = MapView$(dynamic, dynamic); | |
| 3152 let UnmodifiableMapView$ = dart.generic(function(K, V) { | |
| 3153 class UnmodifiableMapView extends dart.mixin(_UnmodifiableMapMixin$(K, V)) { | |
| 3154 } | |
| 3155 return UnmodifiableMapView; | |
| 3156 }); | |
| 3157 let UnmodifiableMapView = UnmodifiableMapView$(dynamic, dynamic); | |
| 3158 class Maps extends dart.Object { | |
| 3159 static containsValue(map, value) { | |
| 3160 for (let v of map.values) { | |
| 3161 if (dart.equals(value, v)) { | |
| 3162 return true; | |
| 3163 } | |
| 3164 } | |
| 3165 return false; | |
| 3166 } | |
| 3167 static containsKey(map, key) { | |
| 3168 for (let k of map.keys) { | |
| 3169 if (dart.equals(key, k)) { | |
| 3170 return true; | |
| 3171 } | |
| 3172 } | |
| 3173 return false; | |
| 3174 } | |
| 3175 static putIfAbsent(map, key, ifAbsent) { | |
| 3176 if (map.containsKey(key)) { | |
| 3177 return map.get(key); | |
| 3178 } | |
| 3179 let v = ifAbsent(); | |
| 3180 map.set(key, v); | |
| 3181 return v; | |
| 3182 } | |
| 3183 static clear(map) { | |
| 3184 for (let k of map.keys.toList()) { | |
| 3185 map.remove(k); | |
| 3186 } | |
| 3187 } | |
| 3188 static forEach(map, f) { | |
| 3189 for (let k of map.keys) { | |
| 3190 f(k, map.get(k)); | |
| 3191 } | |
| 3192 } | |
| 3193 static getValues(map) { | |
| 3194 return map.keys.map((key) => map.get(key)); | |
| 3195 } | |
| 3196 static length(map) { | |
| 3197 return map.keys.length; | |
| 3198 } | |
| 3199 static isEmpty(map) { | |
| 3200 return map.keys.isEmpty; | |
| 3201 } | |
| 3202 static isNotEmpty(map) { | |
| 3203 return map.keys.isNotEmpty; | |
| 3204 } | |
| 3205 static mapToString(m) { | |
| 3206 if (IterableBase._isToStringVisiting(m)) { | |
| 3207 return '{...}'; | |
| 3208 } | |
| 3209 let result = new core.StringBuffer(); | |
| 3210 try { | |
| 3211 IterableBase._toStringVisiting.add(m); | |
| 3212 result.write('{'); | |
| 3213 let first = true; | |
| 3214 m.forEach(((k, v) => { | |
| 3215 if (!dart.notNull(first)) { | |
| 3216 result.write(', '); | |
| 3217 } | |
| 3218 first = false; | |
| 3219 result.write(k); | |
| 3220 result.write(': '); | |
| 3221 result.write(v); | |
| 3222 }).bind(this)); | |
| 3223 result.write('}'); | |
| 3224 } finally { | |
| 3225 dart.assert(core.identical(IterableBase._toStringVisiting.last, m)); | |
| 3226 IterableBase._toStringVisiting.removeLast(); | |
| 3227 } | |
| 3228 return result.toString(); | |
| 3229 } | |
| 3230 static _id(x) { | |
| 3231 return x; | |
| 3232 } | |
| 3233 static _fillMapWithMappedIterable(map, iterable, key, value) { | |
| 3234 if (key === null) | |
| 3235 key = _id; | |
| 3236 if (value === null) | |
| 3237 value = _id; | |
| 3238 for (let element of iterable) { | |
| 3239 map.set(key(element), value(element)); | |
| 3240 } | |
| 3241 } | |
| 3242 static _fillMapWithIterables(map, keys, values) { | |
| 3243 let keyIterator = keys.iterator; | |
| 3244 let valueIterator = values.iterator; | |
| 3245 let hasNextKey = keyIterator.moveNext(); | |
| 3246 let hasNextValue = valueIterator.moveNext(); | |
| 3247 while (dart.notNull(hasNextKey) && dart.notNull(hasNextValue)) { | |
| 3248 map.set(keyIterator.current, valueIterator.current); | |
| 3249 hasNextKey = keyIterator.moveNext(); | |
| 3250 hasNextValue = valueIterator.moveNext(); | |
| 3251 } | |
| 3252 if (dart.notNull(hasNextKey) || dart.notNull(hasNextValue)) { | |
| 3253 throw new core.ArgumentError("Iterables do not have same length."); | |
| 3254 } | |
| 3255 } | |
| 3256 } | |
| 3257 let Queue$ = dart.generic(function(E) { | |
| 3258 class Queue extends dart.Object { | |
| 3259 Queue() { | |
| 3260 return new ListQueue(); | |
| 3261 } | |
| 3262 Queue$from(elements) { | |
| 3263 return new ListQueue.from(elements); | |
| 3264 } | |
| 3265 } | |
| 3266 dart.defineNamedConstructor(Queue, 'from'); | |
| 3267 return Queue; | |
| 3268 }); | |
| 3269 let Queue = Queue$(dynamic); | |
| 3270 let DoubleLinkedQueueEntry$ = dart.generic(function(E) { | |
| 3271 class DoubleLinkedQueueEntry extends dart.Object { | |
| 3272 DoubleLinkedQueueEntry(e) { | |
| 3273 this._element = e; | |
| 3274 this._previous = null; | |
| 3275 this._next = null; | |
| 3276 } | |
| 3277 _link(previous, next) { | |
| 3278 this._next = next; | |
| 3279 this._previous = previous; | |
| 3280 previous._next = this; | |
| 3281 next._previous = this; | |
| 3282 } | |
| 3283 append(e) { | |
| 3284 new DoubleLinkedQueueEntry(e)._link(this, this._next); | |
| 3285 } | |
| 3286 prepend(e) { | |
| 3287 new DoubleLinkedQueueEntry(e)._link(this._previous, this); | |
| 3288 } | |
| 3289 remove() { | |
| 3290 this._previous._next = this._next; | |
| 3291 this._next._previous = this._previous; | |
| 3292 this._next = null; | |
| 3293 this._previous = null; | |
| 3294 return this._element; | |
| 3295 } | |
| 3296 _asNonSentinelEntry() { | |
| 3297 return this; | |
| 3298 } | |
| 3299 previousEntry() { | |
| 3300 return this._previous._asNonSentinelEntry(); | |
| 3301 } | |
| 3302 nextEntry() { | |
| 3303 return this._next._asNonSentinelEntry(); | |
| 3304 } | |
| 3305 get element() { | |
| 3306 return this._element; | |
| 3307 } | |
| 3308 set element(e) { | |
| 3309 this._element = e; | |
| 3310 } | |
| 3311 } | |
| 3312 return DoubleLinkedQueueEntry; | |
| 3313 }); | |
| 3314 let DoubleLinkedQueueEntry = DoubleLinkedQueueEntry$(dynamic); | |
| 3315 let _DoubleLinkedQueueEntrySentinel$ = dart.generic(function(E) { | |
| 3316 class _DoubleLinkedQueueEntrySentinel extends DoubleLinkedQueueEntry$(E) { | |
| 3317 _DoubleLinkedQueueEntrySentinel() { | |
| 3318 super.DoubleLinkedQueueEntry(dart.as(null, E)); | |
| 3319 this._link(this, this); | |
| 3320 } | |
| 3321 remove() { | |
| 3322 throw _internal.IterableElementError.noElement(); | |
| 3323 } | |
| 3324 _asNonSentinelEntry() { | |
| 3325 return null; | |
| 3326 } | |
| 3327 set element(e) { | |
| 3328 dart.assert(false); | |
| 3329 } | |
| 3330 get element() { | |
| 3331 throw _internal.IterableElementError.noElement(); | |
| 3332 } | |
| 3333 } | |
| 3334 return _DoubleLinkedQueueEntrySentinel; | |
| 3335 }); | |
| 3336 let _DoubleLinkedQueueEntrySentinel = _DoubleLinkedQueueEntrySentinel$(dynamic
); | |
| 3337 let DoubleLinkedQueue$ = dart.generic(function(E) { | |
| 3338 class DoubleLinkedQueue extends IterableBase$(E) { | |
| 3339 DoubleLinkedQueue() { | |
| 3340 this._sentinel = null; | |
| 3341 this._elementCount = 0; | |
| 3342 super.IterableBase(); | |
| 3343 this._sentinel = new _DoubleLinkedQueueEntrySentinel(); | |
| 3344 } | |
| 3345 DoubleLinkedQueue$from(elements) { | |
| 3346 let list = dart.as(new DoubleLinkedQueue(), Queue$(E)); | |
| 3347 for (let e of elements) { | |
| 3348 list.addLast(e); | |
| 3349 } | |
| 3350 return dart.as(list, DoubleLinkedQueue$(E)); | |
| 3351 } | |
| 3352 get length() { | |
| 3353 return this._elementCount; | |
| 3354 } | |
| 3355 addLast(value) { | |
| 3356 this._sentinel.prepend(value); | |
| 3357 this._elementCount++; | |
| 3358 } | |
| 3359 addFirst(value) { | |
| 3360 this._sentinel.append(value); | |
| 3361 this._elementCount++; | |
| 3362 } | |
| 3363 add(value) { | |
| 3364 this._sentinel.prepend(value); | |
| 3365 this._elementCount++; | |
| 3366 } | |
| 3367 addAll(iterable) { | |
| 3368 for (let value of iterable) { | |
| 3369 this._sentinel.prepend(value); | |
| 3370 this._elementCount++; | |
| 3371 } | |
| 3372 } | |
| 3373 removeLast() { | |
| 3374 let result = this._sentinel._previous.remove(); | |
| 3375 this._elementCount--; | |
| 3376 return result; | |
| 3377 } | |
| 3378 removeFirst() { | |
| 3379 let result = this._sentinel._next.remove(); | |
| 3380 this._elementCount--; | |
| 3381 return result; | |
| 3382 } | |
| 3383 remove(o) { | |
| 3384 let entry = this._sentinel._next; | |
| 3385 while (!dart.notNull(core.identical(entry, this._sentinel))) { | |
| 3386 if (dart.equals(entry.element, o)) { | |
| 3387 entry.remove(); | |
| 3388 this._elementCount--; | |
| 3389 return true; | |
| 3390 } | |
| 3391 entry = entry._next; | |
| 3392 } | |
| 3393 return false; | |
| 3394 } | |
| 3395 _filter(test, removeMatching) { | |
| 3396 let entry = this._sentinel._next; | |
| 3397 while (!dart.notNull(core.identical(entry, this._sentinel))) { | |
| 3398 let next = entry._next; | |
| 3399 if (core.identical(removeMatching, test(entry.element))) { | |
| 3400 entry.remove(); | |
| 3401 this._elementCount--; | |
| 3402 } | |
| 3403 entry = next; | |
| 3404 } | |
| 3405 } | |
| 3406 removeWhere(test) { | |
| 3407 this._filter(test, true); | |
| 3408 } | |
| 3409 retainWhere(test) { | |
| 3410 this._filter(test, false); | |
| 3411 } | |
| 3412 get first() { | |
| 3413 return this._sentinel._next.element; | |
| 3414 } | |
| 3415 get last() { | |
| 3416 return this._sentinel._previous.element; | |
| 3417 } | |
| 3418 get single() { | |
| 3419 if (core.identical(this._sentinel._next, this._sentinel._previous)) { | |
| 3420 return this._sentinel._next.element; | |
| 3421 } | |
| 3422 throw _internal.IterableElementError.tooMany(); | |
| 3423 } | |
| 3424 lastEntry() { | |
| 3425 return this._sentinel.previousEntry(); | |
| 3426 } | |
| 3427 firstEntry() { | |
| 3428 return this._sentinel.nextEntry(); | |
| 3429 } | |
| 3430 get isEmpty() { | |
| 3431 return core.identical(this._sentinel._next, this._sentinel); | |
| 3432 } | |
| 3433 clear() { | |
| 3434 this._sentinel._next = this._sentinel; | |
| 3435 this._sentinel._previous = this._sentinel; | |
| 3436 this._elementCount = 0; | |
| 3437 } | |
| 3438 forEachEntry(f) { | |
| 3439 let entry = this._sentinel._next; | |
| 3440 while (!dart.notNull(core.identical(entry, this._sentinel))) { | |
| 3441 let nextEntry = entry._next; | |
| 3442 f(entry); | |
| 3443 entry = nextEntry; | |
| 3444 } | |
| 3445 } | |
| 3446 get iterator() { | |
| 3447 return new _DoubleLinkedQueueIterator(this._sentinel); | |
| 3448 } | |
| 3449 toString() { | |
| 3450 return IterableBase.iterableToFullString(this, '{', '}'); | |
| 3451 } | |
| 3452 } | |
| 3453 dart.defineNamedConstructor(DoubleLinkedQueue, 'from'); | |
| 3454 return DoubleLinkedQueue; | |
| 3455 }); | |
| 3456 let DoubleLinkedQueue = DoubleLinkedQueue$(dynamic); | |
| 3457 let _DoubleLinkedQueueIterator$ = dart.generic(function(E) { | |
| 3458 class _DoubleLinkedQueueIterator extends dart.Object { | |
| 3459 _DoubleLinkedQueueIterator(sentinel) { | |
| 3460 this._sentinel = sentinel; | |
| 3461 this._nextEntry = sentinel._next; | |
| 3462 this._current = dart.as(null, E); | |
| 3463 } | |
| 3464 moveNext() { | |
| 3465 if (!dart.notNull(core.identical(this._nextEntry, this._sentinel))) { | |
| 3466 this._current = this._nextEntry._element; | |
| 3467 this._nextEntry = this._nextEntry._next; | |
| 3468 return true; | |
| 3469 } | |
| 3470 this._current = dart.as(null, E); | |
| 3471 this._nextEntry = this._sentinel = null; | |
| 3472 return false; | |
| 3473 } | |
| 3474 get current() { | |
| 3475 return this._current; | |
| 3476 } | |
| 3477 } | |
| 3478 return _DoubleLinkedQueueIterator; | |
| 3479 }); | |
| 3480 let _DoubleLinkedQueueIterator = _DoubleLinkedQueueIterator$(dynamic); | |
| 3481 let ListQueue$ = dart.generic(function(E) { | |
| 3482 class ListQueue extends IterableBase$(E) { | |
| 3483 ListQueue(initialCapacity) { | |
| 3484 if (initialCapacity === void 0) | |
| 3485 initialCapacity = null; | |
| 3486 this._head = 0; | |
| 3487 this._tail = 0; | |
| 3488 this._table = null; | |
| 3489 this._modificationCount = 0; | |
| 3490 super.IterableBase(); | |
| 3491 if (dart.notNull(initialCapacity === null) || dart.notNull(initialCapaci
ty < _INITIAL_CAPACITY)) { | |
| 3492 initialCapacity = _INITIAL_CAPACITY; | |
| 3493 } else if (!dart.notNull(_isPowerOf2(initialCapacity))) { | |
| 3494 initialCapacity = _nextPowerOf2(initialCapacity); | |
| 3495 } | |
| 3496 dart.assert(_isPowerOf2(initialCapacity)); | |
| 3497 this._table = new core.List(initialCapacity); | |
| 3498 } | |
| 3499 ListQueue$from(elements) { | |
| 3500 if (dart.is(elements, core.List)) { | |
| 3501 let length = elements.length; | |
| 3502 let queue = dart.as(new ListQueue(length + 1), ListQueue$(E)); | |
| 3503 dart.assert(queue._table.length > length); | |
| 3504 let sourceList = elements; | |
| 3505 queue._table.setRange(0, length, dart.as(sourceList, core.Iterable$(E)
), 0); | |
| 3506 queue._tail = length; | |
| 3507 return queue; | |
| 3508 } else { | |
| 3509 let capacity = _INITIAL_CAPACITY; | |
| 3510 if (dart.is(elements, _internal.EfficientLength)) { | |
| 3511 capacity = elements.length; | |
| 3512 } | |
| 3513 let result = new ListQueue(capacity); | |
| 3514 for (let element of elements) { | |
| 3515 result.addLast(element); | |
| 3516 } | |
| 3517 return result; | |
| 3518 } | |
| 3519 } | |
| 3520 get iterator() { | |
| 3521 return new _ListQueueIterator(this); | |
| 3522 } | |
| 3523 forEach(action) { | |
| 3524 let modificationCount = this._modificationCount; | |
| 3525 for (let i = this._head; i !== this._tail; i = i + 1 & this._table.lengt
h - 1) { | |
| 3526 action(this._table.get(i)); | |
| 3527 this._checkModification(modificationCount); | |
| 3528 } | |
| 3529 } | |
| 3530 get isEmpty() { | |
| 3531 return this._head === this._tail; | |
| 3532 } | |
| 3533 get length() { | |
| 3534 return this._tail - this._head & this._table.length - 1; | |
| 3535 } | |
| 3536 get first() { | |
| 3537 if (this._head === this._tail) | |
| 3538 throw _internal.IterableElementError.noElement(); | |
| 3539 return this._table.get(this._head); | |
| 3540 } | |
| 3541 get last() { | |
| 3542 if (this._head === this._tail) | |
| 3543 throw _internal.IterableElementError.noElement(); | |
| 3544 return this._table.get(this._tail - 1 & this._table.length - 1); | |
| 3545 } | |
| 3546 get single() { | |
| 3547 if (this._head === this._tail) | |
| 3548 throw _internal.IterableElementError.noElement(); | |
| 3549 if (this.length > 1) | |
| 3550 throw _internal.IterableElementError.tooMany(); | |
| 3551 return this._table.get(this._head); | |
| 3552 } | |
| 3553 elementAt(index) { | |
| 3554 core.RangeError.checkValidIndex(index, this); | |
| 3555 return this._table.get(this._head + index & this._table.length - 1); | |
| 3556 } | |
| 3557 toList(opt$) { | |
| 3558 let growable = opt$.growable === void 0 ? true : opt$.growable; | |
| 3559 let list = null; | |
| 3560 if (growable) { | |
| 3561 list = ((_) => { | |
| 3562 _.length = this.length; | |
| 3563 return _; | |
| 3564 }).bind(this)(new core.List()); | |
| 3565 } else { | |
| 3566 list = new core.List(this.length); | |
| 3567 } | |
| 3568 this._writeToList(list); | |
| 3569 return list; | |
| 3570 } | |
| 3571 add(element) { | |
| 3572 this._add(element); | |
| 3573 } | |
| 3574 addAll(elements) { | |
| 3575 if (dart.is(elements, core.List)) { | |
| 3576 let list = dart.as(elements, core.List); | |
| 3577 let addCount = list.length; | |
| 3578 let length = this.length; | |
| 3579 if (length + addCount >= this._table.length) { | |
| 3580 this._preGrow(length + addCount); | |
| 3581 this._table.setRange(length, length + addCount, dart.as(list, core.I
terable$(E)), 0); | |
| 3582 this._tail = addCount; | |
| 3583 } else { | |
| 3584 let endSpace = this._table.length - this._tail; | |
| 3585 if (addCount < endSpace) { | |
| 3586 this._table.setRange(this._tail, this._tail + addCount, dart.as(li
st, core.Iterable$(E)), 0); | |
| 3587 this._tail = addCount; | |
| 3588 } else { | |
| 3589 let preSpace = addCount - endSpace; | |
| 3590 this._table.setRange(this._tail, this._tail + endSpace, dart.as(li
st, core.Iterable$(E)), 0); | |
| 3591 this._table.setRange(0, preSpace, dart.as(list, core.Iterable$(E))
, endSpace); | |
| 3592 this._tail = preSpace; | |
| 3593 } | |
| 3594 } | |
| 3595 this._modificationCount++; | |
| 3596 } else { | |
| 3597 for (let element of elements) | |
| 3598 this._add(element); | |
| 3599 } | |
| 3600 } | |
| 3601 remove(object) { | |
| 3602 for (let i = this._head; i !== this._tail; i = i + 1 & this._table.lengt
h - 1) { | |
| 3603 let element = this._table.get(i); | |
| 3604 if (dart.equals(element, object)) { | |
| 3605 this._remove(i); | |
| 3606 this._modificationCount++; | |
| 3607 return true; | |
| 3608 } | |
| 3609 } | |
| 3610 return false; | |
| 3611 } | |
| 3612 _filterWhere(test, removeMatching) { | |
| 3613 let index = this._head; | |
| 3614 let modificationCount = this._modificationCount; | |
| 3615 let i = this._head; | |
| 3616 while (i !== this._tail) { | |
| 3617 let element = this._table.get(i); | |
| 3618 let remove = core.identical(removeMatching, test(element)); | |
| 3619 this._checkModification(modificationCount); | |
| 3620 if (remove) { | |
| 3621 i = this._remove(i); | |
| 3622 modificationCount = ++this._modificationCount; | |
| 3623 } else { | |
| 3624 i = i + 1 & this._table.length - 1; | |
| 3625 } | |
| 3626 } | |
| 3627 } | |
| 3628 removeWhere(test) { | |
| 3629 this._filterWhere(test, true); | |
| 3630 } | |
| 3631 retainWhere(test) { | |
| 3632 this._filterWhere(test, false); | |
| 3633 } | |
| 3634 clear() { | |
| 3635 if (this._head !== this._tail) { | |
| 3636 for (let i = this._head; i !== this._tail; i = i + 1 & this._table.len
gth - 1) { | |
| 3637 this._table.set(i, dart.as(null, E)); | |
| 3638 } | |
| 3639 this._head = this._tail = 0; | |
| 3640 this._modificationCount++; | |
| 3641 } | |
| 3642 } | |
| 3643 toString() { | |
| 3644 return IterableBase.iterableToFullString(this, "{", "}"); | |
| 3645 } | |
| 3646 addLast(element) { | |
| 3647 this._add(element); | |
| 3648 } | |
| 3649 addFirst(element) { | |
| 3650 this._head = this._head - 1 & this._table.length - 1; | |
| 3651 this._table.set(this._head, element); | |
| 3652 if (this._head === this._tail) | |
| 3653 this._grow(); | |
| 3654 this._modificationCount++; | |
| 3655 } | |
| 3656 removeFirst() { | |
| 3657 if (this._head === this._tail) | |
| 3658 throw _internal.IterableElementError.noElement(); | |
| 3659 this._modificationCount++; | |
| 3660 let result = this._table.get(this._head); | |
| 3661 this._table.set(this._head, dart.as(null, E)); | |
| 3662 this._head = this._head + 1 & this._table.length - 1; | |
| 3663 return result; | |
| 3664 } | |
| 3665 removeLast() { | |
| 3666 if (this._head === this._tail) | |
| 3667 throw _internal.IterableElementError.noElement(); | |
| 3668 this._modificationCount++; | |
| 3669 this._tail = this._tail - 1 & this._table.length - 1; | |
| 3670 let result = this._table.get(this._tail); | |
| 3671 this._table.set(this._tail, dart.as(null, E)); | |
| 3672 return result; | |
| 3673 } | |
| 3674 static _isPowerOf2(number) { | |
| 3675 return (number & number - 1) === 0; | |
| 3676 } | |
| 3677 static _nextPowerOf2(number) { | |
| 3678 dart.assert(number > 0); | |
| 3679 number = (number << 1) - 1; | |
| 3680 for (;;) { | |
| 3681 let nextNumber = number & number - 1; | |
| 3682 if (nextNumber === 0) | |
| 3683 return number; | |
| 3684 number = nextNumber; | |
| 3685 } | |
| 3686 } | |
| 3687 _checkModification(expectedModificationCount) { | |
| 3688 if (expectedModificationCount !== this._modificationCount) { | |
| 3689 throw new core.ConcurrentModificationError(this); | |
| 3690 } | |
| 3691 } | |
| 3692 _add(element) { | |
| 3693 this._table.set(this._tail, element); | |
| 3694 this._tail = this._tail + 1 & this._table.length - 1; | |
| 3695 if (this._head === this._tail) | |
| 3696 this._grow(); | |
| 3697 this._modificationCount++; | |
| 3698 } | |
| 3699 _remove(offset) { | |
| 3700 let mask = this._table.length - 1; | |
| 3701 let startDistance = offset - this._head & mask; | |
| 3702 let endDistance = this._tail - offset & mask; | |
| 3703 if (startDistance < endDistance) { | |
| 3704 let i = offset; | |
| 3705 while (i !== this._head) { | |
| 3706 let prevOffset = i - 1 & mask; | |
| 3707 this._table.set(i, this._table.get(prevOffset)); | |
| 3708 i = prevOffset; | |
| 3709 } | |
| 3710 this._table.set(this._head, dart.as(null, E)); | |
| 3711 this._head = this._head + 1 & mask; | |
| 3712 return offset + 1 & mask; | |
| 3713 } else { | |
| 3714 this._tail = this._tail - 1 & mask; | |
| 3715 let i = offset; | |
| 3716 while (i !== this._tail) { | |
| 3717 let nextOffset = i + 1 & mask; | |
| 3718 this._table.set(i, this._table.get(nextOffset)); | |
| 3719 i = nextOffset; | |
| 3720 } | |
| 3721 this._table.set(this._tail, dart.as(null, E)); | |
| 3722 return offset; | |
| 3723 } | |
| 3724 } | |
| 3725 _grow() { | |
| 3726 let newTable = new core.List(this._table.length * 2); | |
| 3727 let split = this._table.length - this._head; | |
| 3728 newTable.setRange(0, split, this._table, this._head); | |
| 3729 newTable.setRange(split, split + this._head, this._table, 0); | |
| 3730 this._head = 0; | |
| 3731 this._tail = this._table.length; | |
| 3732 this._table = newTable; | |
| 3733 } | |
| 3734 _writeToList(target) { | |
| 3735 dart.assert(target.length >= this.length); | |
| 3736 if (this._head <= this._tail) { | |
| 3737 let length = this._tail - this._head; | |
| 3738 target.setRange(0, length, this._table, this._head); | |
| 3739 return length; | |
| 3740 } else { | |
| 3741 let firstPartSize = this._table.length - this._head; | |
| 3742 target.setRange(0, firstPartSize, this._table, this._head); | |
| 3743 target.setRange(firstPartSize, firstPartSize + this._tail, this._table
, 0); | |
| 3744 return this._tail + firstPartSize; | |
| 3745 } | |
| 3746 } | |
| 3747 _preGrow(newElementCount) { | |
| 3748 dart.assert(newElementCount >= this.length); | |
| 3749 newElementCount = newElementCount >> 1; | |
| 3750 let newCapacity = _nextPowerOf2(newElementCount); | |
| 3751 let newTable = new core.List(newCapacity); | |
| 3752 this._tail = this._writeToList(newTable); | |
| 3753 this._table = newTable; | |
| 3754 this._head = 0; | |
| 3755 } | |
| 3756 } | |
| 3757 dart.defineNamedConstructor(ListQueue, 'from'); | |
| 3758 ListQueue._INITIAL_CAPACITY = 8; | |
| 3759 return ListQueue; | |
| 3760 }); | |
| 3761 let ListQueue = ListQueue$(dynamic); | |
| 3762 let _ListQueueIterator$ = dart.generic(function(E) { | |
| 3763 class _ListQueueIterator extends dart.Object { | |
| 3764 _ListQueueIterator(queue) { | |
| 3765 this._queue = queue; | |
| 3766 this._end = queue._tail; | |
| 3767 this._modificationCount = queue._modificationCount; | |
| 3768 this._position = queue._head; | |
| 3769 this._current = dart.as(null, E); | |
| 3770 } | |
| 3771 get current() { | |
| 3772 return this._current; | |
| 3773 } | |
| 3774 moveNext() { | |
| 3775 this._queue._checkModification(this._modificationCount); | |
| 3776 if (this._position === this._end) { | |
| 3777 this._current = dart.as(null, E); | |
| 3778 return false; | |
| 3779 } | |
| 3780 this._current = dart.as(this._queue._table.get(this._position), E); | |
| 3781 this._position = this._position + 1 & this._queue._table.length - 1; | |
| 3782 return true; | |
| 3783 } | |
| 3784 } | |
| 3785 return _ListQueueIterator; | |
| 3786 }); | |
| 3787 let _ListQueueIterator = _ListQueueIterator$(dynamic); | |
| 3788 let SetMixin$ = dart.generic(function(E) { | |
| 3789 class SetMixin extends dart.Object { | |
| 3790 get isEmpty() { | |
| 3791 return this.length === 0; | |
| 3792 } | |
| 3793 get isNotEmpty() { | |
| 3794 return this.length !== 0; | |
| 3795 } | |
| 3796 clear() { | |
| 3797 this.removeAll(this.toList()); | |
| 3798 } | |
| 3799 addAll(elements) { | |
| 3800 for (let element of elements) | |
| 3801 this.add(element); | |
| 3802 } | |
| 3803 removeAll(elements) { | |
| 3804 for (let element of elements) | |
| 3805 this.remove(element); | |
| 3806 } | |
| 3807 retainAll(elements) { | |
| 3808 let toRemove = this.toSet(); | |
| 3809 for (let o of elements) { | |
| 3810 toRemove.remove(o); | |
| 3811 } | |
| 3812 this.removeAll(toRemove); | |
| 3813 } | |
| 3814 removeWhere(test) { | |
| 3815 let toRemove = new List.from([]); | |
| 3816 for (let element of this) { | |
| 3817 if (test(element)) | |
| 3818 toRemove.add(element); | |
| 3819 } | |
| 3820 this.removeAll(dart.as(toRemove, core.Iterable$(core.Object))); | |
| 3821 } | |
| 3822 retainWhere(test) { | |
| 3823 let toRemove = new List.from([]); | |
| 3824 for (let element of this) { | |
| 3825 if (!dart.notNull(test(element))) | |
| 3826 toRemove.add(element); | |
| 3827 } | |
| 3828 this.removeAll(dart.as(toRemove, core.Iterable$(core.Object))); | |
| 3829 } | |
| 3830 containsAll(other) { | |
| 3831 for (let o of other) { | |
| 3832 if (!dart.notNull(this.contains(o))) | |
| 3833 return false; | |
| 3834 } | |
| 3835 return true; | |
| 3836 } | |
| 3837 union(other) { | |
| 3838 return ((_) => { | |
| 3839 _.addAll(other); | |
| 3840 return _; | |
| 3841 }).bind(this)(this.toSet()); | |
| 3842 } | |
| 3843 intersection(other) { | |
| 3844 let result = this.toSet(); | |
| 3845 for (let element of this) { | |
| 3846 if (!dart.notNull(other.contains(element))) | |
| 3847 result.remove(element); | |
| 3848 } | |
| 3849 return result; | |
| 3850 } | |
| 3851 difference(other) { | |
| 3852 let result = this.toSet(); | |
| 3853 for (let element of this) { | |
| 3854 if (other.contains(element)) | |
| 3855 result.remove(element); | |
| 3856 } | |
| 3857 return result; | |
| 3858 } | |
| 3859 toList(opt$) { | |
| 3860 let growable = opt$.growable === void 0 ? true : opt$.growable; | |
| 3861 let result = growable ? ((_) => { | |
| 3862 _.length = this.length; | |
| 3863 return _; | |
| 3864 }).bind(this)(new core.List()) : new core.List(this.length); | |
| 3865 let i = 0; | |
| 3866 for (let element of this) | |
| 3867 result.set(i++, element); | |
| 3868 return result; | |
| 3869 } | |
| 3870 map(f) { | |
| 3871 return new _internal.EfficientLengthMappedIterable(this, f); | |
| 3872 } | |
| 3873 get single() { | |
| 3874 if (this.length > 1) | |
| 3875 throw _internal.IterableElementError.tooMany(); | |
| 3876 let it = this.iterator; | |
| 3877 if (!dart.notNull(it.moveNext())) | |
| 3878 throw _internal.IterableElementError.noElement(); | |
| 3879 let result = dart.as(it.current, E); | |
| 3880 return result; | |
| 3881 } | |
| 3882 toString() { | |
| 3883 return IterableBase.iterableToFullString(this, '{', '}'); | |
| 3884 } | |
| 3885 where(f) { | |
| 3886 return new _internal.WhereIterable(this, f); | |
| 3887 } | |
| 3888 expand(f) { | |
| 3889 return new _internal.ExpandIterable(this, f); | |
| 3890 } | |
| 3891 forEach(f) { | |
| 3892 for (let element of this) | |
| 3893 f(element); | |
| 3894 } | |
| 3895 reduce(combine) { | |
| 3896 let iterator = this.iterator; | |
| 3897 if (!dart.notNull(iterator.moveNext())) { | |
| 3898 throw _internal.IterableElementError.noElement(); | |
| 3899 } | |
| 3900 let value = iterator.current; | |
| 3901 while (iterator.moveNext()) { | |
| 3902 value = combine(value, iterator.current); | |
| 3903 } | |
| 3904 return value; | |
| 3905 } | |
| 3906 fold(initialValue, combine) { | |
| 3907 let value = initialValue; | |
| 3908 for (let element of this) | |
| 3909 value = combine(value, element); | |
| 3910 return value; | |
| 3911 } | |
| 3912 every(f) { | |
| 3913 for (let element of this) { | |
| 3914 if (!dart.notNull(f(element))) | |
| 3915 return false; | |
| 3916 } | |
| 3917 return true; | |
| 3918 } | |
| 3919 join(separator) { | |
| 3920 if (separator === void 0) | |
| 3921 separator = ""; | |
| 3922 let iterator = this.iterator; | |
| 3923 if (!dart.notNull(iterator.moveNext())) | |
| 3924 return ""; | |
| 3925 let buffer = new core.StringBuffer(); | |
| 3926 if (dart.notNull(separator === null) || dart.notNull(dart.equals(separat
or, ""))) { | |
| 3927 do { | |
| 3928 buffer.write(`${iterator.current}`); | |
| 3929 } while (iterator.moveNext()); | |
| 3930 } else { | |
| 3931 buffer.write(`${iterator.current}`); | |
| 3932 while (iterator.moveNext()) { | |
| 3933 buffer.write(separator); | |
| 3934 buffer.write(`${iterator.current}`); | |
| 3935 } | |
| 3936 } | |
| 3937 return buffer.toString(); | |
| 3938 } | |
| 3939 any(test) { | |
| 3940 for (let element of this) { | |
| 3941 if (test(element)) | |
| 3942 return true; | |
| 3943 } | |
| 3944 return false; | |
| 3945 } | |
| 3946 take(n) { | |
| 3947 return new _internal.TakeIterable(this, n); | |
| 3948 } | |
| 3949 takeWhile(test) { | |
| 3950 return new _internal.TakeWhileIterable(this, test); | |
| 3951 } | |
| 3952 skip(n) { | |
| 3953 return new _internal.SkipIterable(this, n); | |
| 3954 } | |
| 3955 skipWhile(test) { | |
| 3956 return new _internal.SkipWhileIterable(this, test); | |
| 3957 } | |
| 3958 get first() { | |
| 3959 let it = this.iterator; | |
| 3960 if (!dart.notNull(it.moveNext())) { | |
| 3961 throw _internal.IterableElementError.noElement(); | |
| 3962 } | |
| 3963 return dart.as(it.current, E); | |
| 3964 } | |
| 3965 get last() { | |
| 3966 let it = this.iterator; | |
| 3967 if (!dart.notNull(it.moveNext())) { | |
| 3968 throw _internal.IterableElementError.noElement(); | |
| 3969 } | |
| 3970 let result = null; | |
| 3971 do { | |
| 3972 result = dart.as(it.current, E); | |
| 3973 } while (it.moveNext()); | |
| 3974 return result; | |
| 3975 } | |
| 3976 firstWhere(test, opt$) { | |
| 3977 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 3978 for (let element of this) { | |
| 3979 if (test(element)) | |
| 3980 return element; | |
| 3981 } | |
| 3982 if (orElse !== null) | |
| 3983 return orElse(); | |
| 3984 throw _internal.IterableElementError.noElement(); | |
| 3985 } | |
| 3986 lastWhere(test, opt$) { | |
| 3987 let orElse = opt$.orElse === void 0 ? null : opt$.orElse; | |
| 3988 let result = dart.as(null, E); | |
| 3989 let foundMatching = false; | |
| 3990 for (let element of this) { | |
| 3991 if (test(element)) { | |
| 3992 result = element; | |
| 3993 foundMatching = true; | |
| 3994 } | |
| 3995 } | |
| 3996 if (foundMatching) | |
| 3997 return result; | |
| 3998 if (orElse !== null) | |
| 3999 return orElse(); | |
| 4000 throw _internal.IterableElementError.noElement(); | |
| 4001 } | |
| 4002 singleWhere(test) { | |
| 4003 let result = dart.as(null, E); | |
| 4004 let foundMatching = false; | |
| 4005 for (let element of this) { | |
| 4006 if (test(element)) { | |
| 4007 if (foundMatching) { | |
| 4008 throw _internal.IterableElementError.tooMany(); | |
| 4009 } | |
| 4010 result = element; | |
| 4011 foundMatching = true; | |
| 4012 } | |
| 4013 } | |
| 4014 if (foundMatching) | |
| 4015 return result; | |
| 4016 throw _internal.IterableElementError.noElement(); | |
| 4017 } | |
| 4018 elementAt(index) { | |
| 4019 if (!(typeof index == number)) | |
| 4020 throw new core.ArgumentError.notNull("index"); | |
| 4021 core.RangeError.checkNotNegative(index, "index"); | |
| 4022 let elementIndex = 0; | |
| 4023 for (let element of this) { | |
| 4024 if (index === elementIndex) | |
| 4025 return element; | |
| 4026 elementIndex++; | |
| 4027 } | |
| 4028 throw new core.RangeError.index(index, this, "index", null, elementIndex
); | |
| 4029 } | |
| 4030 } | |
| 4031 return SetMixin; | |
| 4032 }); | |
| 4033 let SetMixin = SetMixin$(dynamic); | |
| 4034 let SetBase$ = dart.generic(function(E) { | |
| 4035 class SetBase extends SetMixin$(E) { | |
| 4036 static setToString(set) { | |
| 4037 return IterableBase.iterableToFullString(set, '{', '}'); | |
| 4038 } | |
| 4039 } | |
| 4040 return SetBase; | |
| 4041 }); | |
| 4042 let SetBase = SetBase$(dynamic); | |
| 4043 let _SplayTreeNode$ = dart.generic(function(K) { | |
| 4044 class _SplayTreeNode extends dart.Object { | |
| 4045 _SplayTreeNode(key) { | |
| 4046 this.key = key; | |
| 4047 this.left = null; | |
| 4048 this.right = null; | |
| 4049 } | |
| 4050 } | |
| 4051 return _SplayTreeNode; | |
| 4052 }); | |
| 4053 let _SplayTreeNode = _SplayTreeNode$(dynamic); | |
| 4054 let _SplayTreeMapNode$ = dart.generic(function(K, V) { | |
| 4055 class _SplayTreeMapNode extends _SplayTreeNode$(K) { | |
| 4056 _SplayTreeMapNode(key, value) { | |
| 4057 this.value = value; | |
| 4058 super._SplayTreeNode(key); | |
| 4059 } | |
| 4060 } | |
| 4061 return _SplayTreeMapNode; | |
| 4062 }); | |
| 4063 let _SplayTreeMapNode = _SplayTreeMapNode$(dynamic, dynamic); | |
| 4064 let _SplayTree$ = dart.generic(function(K) { | |
| 4065 class _SplayTree extends dart.Object { | |
| 4066 _SplayTree() { | |
| 4067 this._dummy = new _SplayTreeNode(dart.as(null, K)); | |
| 4068 this._root = null; | |
| 4069 this._count = 0; | |
| 4070 this._modificationCount = 0; | |
| 4071 this._splayCount = 0; | |
| 4072 } | |
| 4073 _splay(key) { | |
| 4074 if (this._root === null) | |
| 4075 return -1; | |
| 4076 let left = this._dummy; | |
| 4077 let right = this._dummy; | |
| 4078 let current = this._root; | |
| 4079 let comp = null; | |
| 4080 while (true) { | |
| 4081 comp = this._compare(current.key, key); | |
| 4082 if (comp > 0) { | |
| 4083 if (current.left === null) | |
| 4084 break; | |
| 4085 comp = this._compare(current.left.key, key); | |
| 4086 if (comp > 0) { | |
| 4087 let tmp = current.left; | |
| 4088 current.left = tmp.right; | |
| 4089 tmp.right = current; | |
| 4090 current = tmp; | |
| 4091 if (current.left === null) | |
| 4092 break; | |
| 4093 } | |
| 4094 right.left = current; | |
| 4095 right = current; | |
| 4096 current = current.left; | |
| 4097 } else if (comp < 0) { | |
| 4098 if (current.right === null) | |
| 4099 break; | |
| 4100 comp = this._compare(current.right.key, key); | |
| 4101 if (comp < 0) { | |
| 4102 let tmp = current.right; | |
| 4103 current.right = tmp.left; | |
| 4104 tmp.left = current; | |
| 4105 current = tmp; | |
| 4106 if (current.right === null) | |
| 4107 break; | |
| 4108 } | |
| 4109 left.right = current; | |
| 4110 left = current; | |
| 4111 current = current.right; | |
| 4112 } else { | |
| 4113 break; | |
| 4114 } | |
| 4115 } | |
| 4116 left.right = current.left; | |
| 4117 right.left = current.right; | |
| 4118 current.left = this._dummy.right; | |
| 4119 current.right = this._dummy.left; | |
| 4120 this._root = current; | |
| 4121 this._dummy.right = null; | |
| 4122 this._dummy.left = null; | |
| 4123 this._splayCount++; | |
| 4124 return comp; | |
| 4125 } | |
| 4126 _splayMin(node) { | |
| 4127 let current = node; | |
| 4128 while (current.left !== null) { | |
| 4129 let left = current.left; | |
| 4130 current.left = left.right; | |
| 4131 left.right = current; | |
| 4132 current = left; | |
| 4133 } | |
| 4134 return dart.as(current, _SplayTreeNode$(K)); | |
| 4135 } | |
| 4136 _splayMax(node) { | |
| 4137 let current = node; | |
| 4138 while (current.right !== null) { | |
| 4139 let right = current.right; | |
| 4140 current.right = right.left; | |
| 4141 right.left = current; | |
| 4142 current = right; | |
| 4143 } | |
| 4144 return dart.as(current, _SplayTreeNode$(K)); | |
| 4145 } | |
| 4146 _remove(key) { | |
| 4147 if (this._root === null) | |
| 4148 return null; | |
| 4149 let comp = this._splay(key); | |
| 4150 if (comp !== 0) | |
| 4151 return null; | |
| 4152 let result = this._root; | |
| 4153 this._count--; | |
| 4154 if (this._root.left === null) { | |
| 4155 this._root = this._root.right; | |
| 4156 } else { | |
| 4157 let right = this._root.right; | |
| 4158 this._root = this._splayMax(this._root.left); | |
| 4159 this._root.right = right; | |
| 4160 } | |
| 4161 this._modificationCount++; | |
| 4162 return result; | |
| 4163 } | |
| 4164 _addNewRoot(node, comp) { | |
| 4165 this._count++; | |
| 4166 this._modificationCount++; | |
| 4167 if (this._root === null) { | |
| 4168 this._root = node; | |
| 4169 return; | |
| 4170 } | |
| 4171 if (comp < 0) { | |
| 4172 node.left = this._root; | |
| 4173 node.right = this._root.right; | |
| 4174 this._root.right = null; | |
| 4175 } else { | |
| 4176 node.right = this._root; | |
| 4177 node.left = this._root.left; | |
| 4178 this._root.left = null; | |
| 4179 } | |
| 4180 this._root = node; | |
| 4181 } | |
| 4182 get _first() { | |
| 4183 if (this._root === null) | |
| 4184 return null; | |
| 4185 this._root = this._splayMin(this._root); | |
| 4186 return this._root; | |
| 4187 } | |
| 4188 get _last() { | |
| 4189 if (this._root === null) | |
| 4190 return null; | |
| 4191 this._root = this._splayMax(this._root); | |
| 4192 return this._root; | |
| 4193 } | |
| 4194 _clear() { | |
| 4195 this._root = null; | |
| 4196 this._count = 0; | |
| 4197 this._modificationCount++; | |
| 4198 } | |
| 4199 } | |
| 4200 return _SplayTree; | |
| 4201 }); | |
| 4202 let _SplayTree = _SplayTree$(dynamic); | |
| 4203 let _TypeTest$ = dart.generic(function(T) { | |
| 4204 class _TypeTest extends dart.Object { | |
| 4205 test(v) { | |
| 4206 return dart.is(v, T); | |
| 4207 } | |
| 4208 } | |
| 4209 return _TypeTest; | |
| 4210 }); | |
| 4211 let _TypeTest = _TypeTest$(dynamic); | |
| 4212 let SplayTreeMap$ = dart.generic(function(K, V) { | |
| 4213 class SplayTreeMap extends _SplayTree$(K) { | |
| 4214 SplayTreeMap(compare, isValidKey) { | |
| 4215 if (compare === void 0) | |
| 4216 compare = null; | |
| 4217 if (isValidKey === void 0) | |
| 4218 isValidKey = null; | |
| 4219 this._comparator = dart.as(compare === null ? core.Comparable.compare :
compare, core.Comparator); | |
| 4220 this._validKey = dart.as(isValidKey !== null ? isValidKey : (v) => dart.
is(v, K), _Predicate); | |
| 4221 super._SplayTree(); | |
| 4222 } | |
| 4223 SplayTreeMap$from(other, compare, isValidKey) { | |
| 4224 if (compare === void 0) | |
| 4225 compare = null; | |
| 4226 if (isValidKey === void 0) | |
| 4227 isValidKey = null; | |
| 4228 let result = new SplayTreeMap(); | |
| 4229 other.forEach((k, v) => { | |
| 4230 result.set(k, dart.as(v, V)); | |
| 4231 }); | |
| 4232 return result; | |
| 4233 } | |
| 4234 SplayTreeMap$fromIterable(iterable, opt$) { | |
| 4235 let key = opt$.key === void 0 ? null : opt$.key; | |
| 4236 let value = opt$.value === void 0 ? null : opt$.value; | |
| 4237 let compare = opt$.compare === void 0 ? null : opt$.compare; | |
| 4238 let isValidKey = opt$.isValidKey === void 0 ? null : opt$.isValidKey; | |
| 4239 let map = new SplayTreeMap(compare, isValidKey); | |
| 4240 Maps._fillMapWithMappedIterable(map, iterable, key, value); | |
| 4241 return map; | |
| 4242 } | |
| 4243 SplayTreeMap$fromIterables(keys, values, compare, isValidKey) { | |
| 4244 if (compare === void 0) | |
| 4245 compare = null; | |
| 4246 if (isValidKey === void 0) | |
| 4247 isValidKey = null; | |
| 4248 let map = new SplayTreeMap(compare, isValidKey); | |
| 4249 Maps._fillMapWithIterables(map, keys, values); | |
| 4250 return map; | |
| 4251 } | |
| 4252 _compare(key1, key2) { | |
| 4253 return this._comparator(key1, key2); | |
| 4254 } | |
| 4255 SplayTreeMap$_internal() { | |
| 4256 this._comparator = null; | |
| 4257 this._validKey = null; | |
| 4258 super._SplayTree(); | |
| 4259 } | |
| 4260 get(key) { | |
| 4261 if (key === null) | |
| 4262 throw new core.ArgumentError(key); | |
| 4263 if (!dart.notNull(this._validKey(key))) | |
| 4264 return dart.as(null, V); | |
| 4265 if (this._root !== null) { | |
| 4266 let comp = this._splay(dart.as(key, K)); | |
| 4267 if (comp === 0) { | |
| 4268 let mapRoot = dart.as(this._root, _SplayTreeMapNode); | |
| 4269 return dart.as(mapRoot.value, V); | |
| 4270 } | |
| 4271 } | |
| 4272 return dart.as(null, V); | |
| 4273 } | |
| 4274 remove(key) { | |
| 4275 if (!dart.notNull(this._validKey(key))) | |
| 4276 return dart.as(null, V); | |
| 4277 let mapRoot = dart.as(this._remove(dart.as(key, K)), _SplayTreeMapNode); | |
| 4278 if (mapRoot !== null) | |
| 4279 return dart.as(mapRoot.value, V); | |
| 4280 return dart.as(null, V); | |
| 4281 } | |
| 4282 set(key, value) { | |
| 4283 if (key === null) | |
| 4284 throw new core.ArgumentError(key); | |
| 4285 let comp = this._splay(key); | |
| 4286 if (comp === 0) { | |
| 4287 let mapRoot = dart.as(this._root, _SplayTreeMapNode); | |
| 4288 mapRoot.value = value; | |
| 4289 return; | |
| 4290 } | |
| 4291 this._addNewRoot(dart.as(new _SplayTreeMapNode(key, value), _SplayTreeNo
de$(K)), comp); | |
| 4292 } | |
| 4293 putIfAbsent(key, ifAbsent) { | |
| 4294 if (key === null) | |
| 4295 throw new core.ArgumentError(key); | |
| 4296 let comp = this._splay(key); | |
| 4297 if (comp === 0) { | |
| 4298 let mapRoot = dart.as(this._root, _SplayTreeMapNode); | |
| 4299 return dart.as(mapRoot.value, V); | |
| 4300 } | |
| 4301 let modificationCount = this._modificationCount; | |
| 4302 let splayCount = this._splayCount; | |
| 4303 let value = ifAbsent(); | |
| 4304 if (modificationCount !== this._modificationCount) { | |
| 4305 throw new core.ConcurrentModificationError(this); | |
| 4306 } | |
| 4307 if (splayCount !== this._splayCount) { | |
| 4308 comp = this._splay(key); | |
| 4309 dart.assert(comp !== 0); | |
| 4310 } | |
| 4311 this._addNewRoot(dart.as(new _SplayTreeMapNode(key, value), _SplayTreeNo
de$(K)), comp); | |
| 4312 return value; | |
| 4313 } | |
| 4314 addAll(other) { | |
| 4315 other.forEach(((key, value) => { | |
| 4316 this.set(key, value); | |
| 4317 }).bind(this)); | |
| 4318 } | |
| 4319 get isEmpty() { | |
| 4320 return this._root === null; | |
| 4321 } | |
| 4322 get isNotEmpty() { | |
| 4323 return !dart.notNull(this.isEmpty); | |
| 4324 } | |
| 4325 forEach(f) { | |
| 4326 let nodes = new _SplayTreeNodeIterator(this); | |
| 4327 while (nodes.moveNext()) { | |
| 4328 let node = dart.as(nodes.current, _SplayTreeMapNode$(K, V)); | |
| 4329 f(node.key, node.value); | |
| 4330 } | |
| 4331 } | |
| 4332 get length() { | |
| 4333 return this._count; | |
| 4334 } | |
| 4335 clear() { | |
| 4336 this._clear(); | |
| 4337 } | |
| 4338 containsKey(key) { | |
| 4339 return dart.notNull(this._validKey(key)) && dart.notNull(this._splay(dar
t.as(key, K)) === 0); | |
| 4340 } | |
| 4341 containsValue(value) { | |
| 4342 let found = false; | |
| 4343 let initialSplayCount = this._splayCount; | |
| 4344 // Function visit: (_SplayTreeMapNode<dynamic, dynamic>) → bool | |
| 4345 function visit(node) { | |
| 4346 while (node !== null) { | |
| 4347 if (dart.equals(node.value, value)) | |
| 4348 return true; | |
| 4349 if (initialSplayCount !== this._splayCount) { | |
| 4350 throw new core.ConcurrentModificationError(this); | |
| 4351 } | |
| 4352 if (dart.notNull(node.right !== null) && dart.notNull(visit(dart.as(
node.right, _SplayTreeMapNode)))) | |
| 4353 return true; | |
| 4354 node = dart.as(node.left, _SplayTreeMapNode); | |
| 4355 } | |
| 4356 return false; | |
| 4357 } | |
| 4358 return visit(dart.as(this._root, _SplayTreeMapNode)); | |
| 4359 } | |
| 4360 get keys() { | |
| 4361 return new _SplayTreeKeyIterable(this); | |
| 4362 } | |
| 4363 get values() { | |
| 4364 return new _SplayTreeValueIterable(this); | |
| 4365 } | |
| 4366 toString() { | |
| 4367 return Maps.mapToString(this); | |
| 4368 } | |
| 4369 firstKey() { | |
| 4370 if (this._root === null) | |
| 4371 return dart.as(null, K); | |
| 4372 return dart.as(this._first.key, K); | |
| 4373 } | |
| 4374 lastKey() { | |
| 4375 if (this._root === null) | |
| 4376 return dart.as(null, K); | |
| 4377 return dart.as(this._last.key, K); | |
| 4378 } | |
| 4379 lastKeyBefore(key) { | |
| 4380 if (key === null) | |
| 4381 throw new core.ArgumentError(key); | |
| 4382 if (this._root === null) | |
| 4383 return dart.as(null, K); | |
| 4384 let comp = this._splay(key); | |
| 4385 if (comp < 0) | |
| 4386 return this._root.key; | |
| 4387 let node = this._root.left; | |
| 4388 if (node === null) | |
| 4389 return dart.as(null, K); | |
| 4390 while (node.right !== null) { | |
| 4391 node = node.right; | |
| 4392 } | |
| 4393 return node.key; | |
| 4394 } | |
| 4395 firstKeyAfter(key) { | |
| 4396 if (key === null) | |
| 4397 throw new core.ArgumentError(key); | |
| 4398 if (this._root === null) | |
| 4399 return dart.as(null, K); | |
| 4400 let comp = this._splay(key); | |
| 4401 if (comp > 0) | |
| 4402 return this._root.key; | |
| 4403 let node = this._root.right; | |
| 4404 if (node === null) | |
| 4405 return dart.as(null, K); | |
| 4406 while (node.left !== null) { | |
| 4407 node = node.left; | |
| 4408 } | |
| 4409 return node.key; | |
| 4410 } | |
| 4411 } | |
| 4412 dart.defineNamedConstructor(SplayTreeMap, 'from'); | |
| 4413 dart.defineNamedConstructor(SplayTreeMap, 'fromIterable'); | |
| 4414 dart.defineNamedConstructor(SplayTreeMap, 'fromIterables'); | |
| 4415 dart.defineNamedConstructor(SplayTreeMap, '_internal'); | |
| 4416 return SplayTreeMap; | |
| 4417 }); | |
| 4418 let SplayTreeMap = SplayTreeMap$(dynamic, dynamic); | |
| 4419 let _SplayTreeIterator$ = dart.generic(function(T) { | |
| 4420 class _SplayTreeIterator extends dart.Object { | |
| 4421 _SplayTreeIterator(tree) { | |
| 4422 this._workList = new List.from([]); | |
| 4423 this._tree = tree; | |
| 4424 this._modificationCount = tree._modificationCount; | |
| 4425 this._splayCount = tree._splayCount; | |
| 4426 this._currentNode = null; | |
| 4427 this._findLeftMostDescendent(tree._root); | |
| 4428 } | |
| 4429 _SplayTreeIterator$startAt(tree, startKey) { | |
| 4430 this._workList = new List.from([]); | |
| 4431 this._tree = tree; | |
| 4432 this._modificationCount = tree._modificationCount; | |
| 4433 this._splayCount = dart.as(null, core.int); | |
| 4434 this._currentNode = null; | |
| 4435 if (tree._root === null) | |
| 4436 return; | |
| 4437 let compare = tree._splay(startKey); | |
| 4438 this._splayCount = tree._splayCount; | |
| 4439 if (compare < 0) { | |
| 4440 this._findLeftMostDescendent(tree._root.right); | |
| 4441 } else { | |
| 4442 this._workList.add(tree._root); | |
| 4443 } | |
| 4444 } | |
| 4445 get current() { | |
| 4446 if (this._currentNode === null) | |
| 4447 return dart.as(null, T); | |
| 4448 return this._getValue(this._currentNode); | |
| 4449 } | |
| 4450 _findLeftMostDescendent(node) { | |
| 4451 while (node !== null) { | |
| 4452 this._workList.add(node); | |
| 4453 node = node.left; | |
| 4454 } | |
| 4455 } | |
| 4456 _rebuildWorkList(currentNode) { | |
| 4457 dart.assert(!dart.notNull(this._workList.isEmpty)); | |
| 4458 this._workList.clear(); | |
| 4459 if (currentNode === null) { | |
| 4460 this._findLeftMostDescendent(this._tree._root); | |
| 4461 } else { | |
| 4462 this._tree._splay(currentNode.key); | |
| 4463 this._findLeftMostDescendent(this._tree._root.right); | |
| 4464 dart.assert(!dart.notNull(this._workList.isEmpty)); | |
| 4465 } | |
| 4466 } | |
| 4467 moveNext() { | |
| 4468 if (this._modificationCount !== this._tree._modificationCount) { | |
| 4469 throw new core.ConcurrentModificationError(this._tree); | |
| 4470 } | |
| 4471 if (this._workList.isEmpty) { | |
| 4472 this._currentNode = null; | |
| 4473 return false; | |
| 4474 } | |
| 4475 if (dart.notNull(this._tree._splayCount !== this._splayCount) && dart.no
tNull(this._currentNode !== null)) { | |
| 4476 this._rebuildWorkList(this._currentNode); | |
| 4477 } | |
| 4478 this._currentNode = this._workList.removeLast(); | |
| 4479 this._findLeftMostDescendent(this._currentNode.right); | |
| 4480 return true; | |
| 4481 } | |
| 4482 } | |
| 4483 dart.defineNamedConstructor(_SplayTreeIterator, 'startAt'); | |
| 4484 return _SplayTreeIterator; | |
| 4485 }); | |
| 4486 let _SplayTreeIterator = _SplayTreeIterator$(dynamic); | |
| 4487 let _SplayTreeKeyIterable$ = dart.generic(function(K) { | |
| 4488 class _SplayTreeKeyIterable extends IterableBase$(K) { | |
| 4489 _SplayTreeKeyIterable(_tree) { | |
| 4490 this._tree = _tree; | |
| 4491 super.IterableBase(); | |
| 4492 } | |
| 4493 get length() { | |
| 4494 return this._tree._count; | |
| 4495 } | |
| 4496 get isEmpty() { | |
| 4497 return this._tree._count === 0; | |
| 4498 } | |
| 4499 get iterator() { | |
| 4500 return new _SplayTreeKeyIterator(this._tree); | |
| 4501 } | |
| 4502 toSet() { | |
| 4503 let setOrMap = this._tree; | |
| 4504 let set = new SplayTreeSet(dart.as(setOrMap._comparator, dart.throw_("Un
implemented type (K, K) → int")), dart.as(setOrMap._validKey, dart.throw_("Unimp
lemented type (dynamic) → bool"))); | |
| 4505 set._count = this._tree._count; | |
| 4506 set._root = set._copyNode(this._tree._root); | |
| 4507 return set; | |
| 4508 } | |
| 4509 } | |
| 4510 return _SplayTreeKeyIterable; | |
| 4511 }); | |
| 4512 let _SplayTreeKeyIterable = _SplayTreeKeyIterable$(dynamic); | |
| 4513 let _SplayTreeValueIterable$ = dart.generic(function(K, V) { | |
| 4514 class _SplayTreeValueIterable extends IterableBase$(V) { | |
| 4515 _SplayTreeValueIterable(_map) { | |
| 4516 this._map = _map; | |
| 4517 super.IterableBase(); | |
| 4518 } | |
| 4519 get length() { | |
| 4520 return this._map._count; | |
| 4521 } | |
| 4522 get isEmpty() { | |
| 4523 return this._map._count === 0; | |
| 4524 } | |
| 4525 get iterator() { | |
| 4526 return new _SplayTreeValueIterator(this._map); | |
| 4527 } | |
| 4528 } | |
| 4529 return _SplayTreeValueIterable; | |
| 4530 }); | |
| 4531 let _SplayTreeValueIterable = _SplayTreeValueIterable$(dynamic, dynamic); | |
| 4532 let _SplayTreeKeyIterator$ = dart.generic(function(K) { | |
| 4533 class _SplayTreeKeyIterator extends _SplayTreeIterator$(K) { | |
| 4534 _SplayTreeKeyIterator(map) { | |
| 4535 super._SplayTreeIterator(map); | |
| 4536 } | |
| 4537 _getValue(node) { | |
| 4538 return dart.as(node.key, K); | |
| 4539 } | |
| 4540 } | |
| 4541 return _SplayTreeKeyIterator; | |
| 4542 }); | |
| 4543 let _SplayTreeKeyIterator = _SplayTreeKeyIterator$(dynamic); | |
| 4544 let _SplayTreeValueIterator$ = dart.generic(function(K, V) { | |
| 4545 class _SplayTreeValueIterator extends _SplayTreeIterator$(V) { | |
| 4546 _SplayTreeValueIterator(map) { | |
| 4547 super._SplayTreeIterator(map); | |
| 4548 } | |
| 4549 _getValue(node) { | |
| 4550 return dart.as(node.value, V); | |
| 4551 } | |
| 4552 } | |
| 4553 return _SplayTreeValueIterator; | |
| 4554 }); | |
| 4555 let _SplayTreeValueIterator = _SplayTreeValueIterator$(dynamic, dynamic); | |
| 4556 let _SplayTreeNodeIterator$ = dart.generic(function(K) { | |
| 4557 class _SplayTreeNodeIterator extends _SplayTreeIterator$(_SplayTreeNode$(K))
{ | |
| 4558 _SplayTreeNodeIterator(tree) { | |
| 4559 super._SplayTreeIterator(tree); | |
| 4560 } | |
| 4561 _SplayTreeNodeIterator$startAt(tree, startKey) { | |
| 4562 super._SplayTreeIterator$startAt(tree, startKey); | |
| 4563 } | |
| 4564 _getValue(node) { | |
| 4565 return dart.as(node, _SplayTreeNode$(K)); | |
| 4566 } | |
| 4567 } | |
| 4568 dart.defineNamedConstructor(_SplayTreeNodeIterator, 'startAt'); | |
| 4569 return _SplayTreeNodeIterator; | |
| 4570 }); | |
| 4571 let _SplayTreeNodeIterator = _SplayTreeNodeIterator$(dynamic); | |
| 4572 let SplayTreeSet$ = dart.generic(function(E) { | |
| 4573 class SplayTreeSet extends dart.mixin(_SplayTree$(E), IterableMixin$(E), Set
Mixin$(E)) { | |
| 4574 SplayTreeSet(compare, isValidKey) { | |
| 4575 if (compare === void 0) | |
| 4576 compare = null; | |
| 4577 if (isValidKey === void 0) | |
| 4578 isValidKey = null; | |
| 4579 this._comparator = dart.as(compare === null ? core.Comparable.compare :
compare, core.Comparator); | |
| 4580 this._validKey = dart.as(isValidKey !== null ? isValidKey : (v) => dart.
is(v, E), _Predicate); | |
| 4581 super._SplayTree(); | |
| 4582 } | |
| 4583 SplayTreeSet$from(elements, compare, isValidKey) { | |
| 4584 if (compare === void 0) | |
| 4585 compare = null; | |
| 4586 if (isValidKey === void 0) | |
| 4587 isValidKey = null; | |
| 4588 let result = new SplayTreeSet(compare, isValidKey); | |
| 4589 for (let element of elements) { | |
| 4590 result.add(element); | |
| 4591 } | |
| 4592 return result; | |
| 4593 } | |
| 4594 _compare(e1, e2) { | |
| 4595 return this._comparator(e1, e2); | |
| 4596 } | |
| 4597 get iterator() { | |
| 4598 return new _SplayTreeKeyIterator(this); | |
| 4599 } | |
| 4600 get length() { | |
| 4601 return this._count; | |
| 4602 } | |
| 4603 get isEmpty() { | |
| 4604 return this._root === null; | |
| 4605 } | |
| 4606 get isNotEmpty() { | |
| 4607 return this._root !== null; | |
| 4608 } | |
| 4609 get first() { | |
| 4610 if (this._count === 0) | |
| 4611 throw _internal.IterableElementError.noElement(); | |
| 4612 return dart.as(this._first.key, E); | |
| 4613 } | |
| 4614 get last() { | |
| 4615 if (this._count === 0) | |
| 4616 throw _internal.IterableElementError.noElement(); | |
| 4617 return dart.as(this._last.key, E); | |
| 4618 } | |
| 4619 get single() { | |
| 4620 if (this._count === 0) | |
| 4621 throw _internal.IterableElementError.noElement(); | |
| 4622 if (this._count > 1) | |
| 4623 throw _internal.IterableElementError.tooMany(); | |
| 4624 return this._root.key; | |
| 4625 } | |
| 4626 contains(object) { | |
| 4627 return dart.notNull(this._validKey(object)) && dart.notNull(this._splay(
dart.as(object, E)) === 0); | |
| 4628 } | |
| 4629 add(element) { | |
| 4630 let compare = this._splay(element); | |
| 4631 if (compare === 0) | |
| 4632 return false; | |
| 4633 this._addNewRoot(dart.as(new _SplayTreeNode(element), _SplayTreeNode$(E)
), compare); | |
| 4634 return true; | |
| 4635 } | |
| 4636 remove(object) { | |
| 4637 if (!dart.notNull(this._validKey(object))) | |
| 4638 return false; | |
| 4639 return this._remove(dart.as(object, E)) !== null; | |
| 4640 } | |
| 4641 addAll(elements) { | |
| 4642 for (let element of elements) { | |
| 4643 let compare = this._splay(element); | |
| 4644 if (compare !== 0) { | |
| 4645 this._addNewRoot(dart.as(new _SplayTreeNode(element), _SplayTreeNode
$(E)), compare); | |
| 4646 } | |
| 4647 } | |
| 4648 } | |
| 4649 removeAll(elements) { | |
| 4650 for (let element of elements) { | |
| 4651 if (this._validKey(element)) | |
| 4652 this._remove(dart.as(element, E)); | |
| 4653 } | |
| 4654 } | |
| 4655 retainAll(elements) { | |
| 4656 let retainSet = new SplayTreeSet(this._comparator, this._validKey); | |
| 4657 let modificationCount = this._modificationCount; | |
| 4658 for (let object of elements) { | |
| 4659 if (modificationCount !== this._modificationCount) { | |
| 4660 throw new core.ConcurrentModificationError(this); | |
| 4661 } | |
| 4662 if (dart.notNull(this._validKey(object)) && dart.notNull(this._splay(d
art.as(object, E)) === 0)) | |
| 4663 retainSet.add(this._root.key); | |
| 4664 } | |
| 4665 if (retainSet._count !== this._count) { | |
| 4666 this._root = retainSet._root; | |
| 4667 this._count = retainSet._count; | |
| 4668 this._modificationCount++; | |
| 4669 } | |
| 4670 } | |
| 4671 lookup(object) { | |
| 4672 if (!dart.notNull(this._validKey(object))) | |
| 4673 return dart.as(null, E); | |
| 4674 let comp = this._splay(dart.as(object, E)); | |
| 4675 if (comp !== 0) | |
| 4676 return dart.as(null, E); | |
| 4677 return this._root.key; | |
| 4678 } | |
| 4679 intersection(other) { | |
| 4680 let result = new SplayTreeSet(this._comparator, this._validKey); | |
| 4681 for (let element of this) { | |
| 4682 if (other.contains(element)) | |
| 4683 result.add(element); | |
| 4684 } | |
| 4685 return result; | |
| 4686 } | |
| 4687 difference(other) { | |
| 4688 let result = new SplayTreeSet(this._comparator, this._validKey); | |
| 4689 for (let element of this) { | |
| 4690 if (!dart.notNull(other.contains(element))) | |
| 4691 result.add(element); | |
| 4692 } | |
| 4693 return result; | |
| 4694 } | |
| 4695 union(other) { | |
| 4696 return ((_) => { | |
| 4697 _.addAll(other); | |
| 4698 return _; | |
| 4699 }).bind(this)(this._clone()); | |
| 4700 } | |
| 4701 _clone() { | |
| 4702 let set = new SplayTreeSet(this._comparator, this._validKey); | |
| 4703 set._count = this._count; | |
| 4704 set._root = this._copyNode(this._root); | |
| 4705 return set; | |
| 4706 } | |
| 4707 _copyNode(node) { | |
| 4708 if (node === null) | |
| 4709 return null; | |
| 4710 return ((_) => { | |
| 4711 _.left = this._copyNode(node.left); | |
| 4712 _.right = this._copyNode(node.right); | |
| 4713 return _; | |
| 4714 }).bind(this)(new _SplayTreeNode(node.key)); | |
| 4715 } | |
| 4716 clear() { | |
| 4717 this._clear(); | |
| 4718 } | |
| 4719 toSet() { | |
| 4720 return this._clone(); | |
| 4721 } | |
| 4722 toString() { | |
| 4723 return IterableBase.iterableToFullString(this, '{', '}'); | |
| 4724 } | |
| 4725 } | |
| 4726 dart.defineNamedConstructor(SplayTreeSet, 'from'); | |
| 4727 return SplayTreeSet; | |
| 4728 }); | |
| 4729 let SplayTreeSet = SplayTreeSet$(dynamic); | |
| 4730 // Exports: | |
| 4731 exports.HashMapKeyIterable = HashMapKeyIterable; | |
| 4732 exports.HashMapKeyIterable$ = HashMapKeyIterable$; | |
| 4733 exports.HashMapKeyIterator = HashMapKeyIterator; | |
| 4734 exports.HashMapKeyIterator$ = HashMapKeyIterator$; | |
| 4735 exports.LinkedHashMapCell = LinkedHashMapCell; | |
| 4736 exports.LinkedHashMapKeyIterable = LinkedHashMapKeyIterable; | |
| 4737 exports.LinkedHashMapKeyIterable$ = LinkedHashMapKeyIterable$; | |
| 4738 exports.LinkedHashMapKeyIterator = LinkedHashMapKeyIterator; | |
| 4739 exports.LinkedHashMapKeyIterator$ = LinkedHashMapKeyIterator$; | |
| 4740 exports.HashSetIterator = HashSetIterator; | |
| 4741 exports.HashSetIterator$ = HashSetIterator$; | |
| 4742 exports.LinkedHashSetCell = LinkedHashSetCell; | |
| 4743 exports.LinkedHashSetIterator = LinkedHashSetIterator; | |
| 4744 exports.LinkedHashSetIterator$ = LinkedHashSetIterator$; | |
| 4745 exports.UnmodifiableListView = UnmodifiableListView; | |
| 4746 exports.UnmodifiableListView$ = UnmodifiableListView$; | |
| 4747 exports.HashMap = HashMap; | |
| 4748 exports.HashMap$ = HashMap$; | |
| 4749 exports.HashSet = HashSet; | |
| 4750 exports.HashSet$ = HashSet$; | |
| 4751 exports.IterableMixin = IterableMixin; | |
| 4752 exports.IterableMixin$ = IterableMixin$; | |
| 4753 exports.IterableBase = IterableBase; | |
| 4754 exports.IterableBase$ = IterableBase$; | |
| 4755 exports.HasNextIterator = HasNextIterator; | |
| 4756 exports.HasNextIterator$ = HasNextIterator$; | |
| 4757 exports.LinkedHashMap = LinkedHashMap; | |
| 4758 exports.LinkedHashMap$ = LinkedHashMap$; | |
| 4759 exports.LinkedHashSet = LinkedHashSet; | |
| 4760 exports.LinkedHashSet$ = LinkedHashSet$; | |
| 4761 exports.LinkedList = LinkedList; | |
| 4762 exports.LinkedList$ = LinkedList$; | |
| 4763 exports.LinkedListEntry = LinkedListEntry; | |
| 4764 exports.LinkedListEntry$ = LinkedListEntry$; | |
| 4765 exports.ListBase = ListBase; | |
| 4766 exports.ListBase$ = ListBase$; | |
| 4767 exports.ListMixin = ListMixin; | |
| 4768 exports.ListMixin$ = ListMixin$; | |
| 4769 exports.MapBase = MapBase; | |
| 4770 exports.MapBase$ = MapBase$; | |
| 4771 exports.MapMixin = MapMixin; | |
| 4772 exports.MapMixin$ = MapMixin$; | |
| 4773 exports.UnmodifiableMapBase = UnmodifiableMapBase; | |
| 4774 exports.UnmodifiableMapBase$ = UnmodifiableMapBase$; | |
| 4775 exports.MapView = MapView; | |
| 4776 exports.MapView$ = MapView$; | |
| 4777 exports.UnmodifiableMapView = UnmodifiableMapView; | |
| 4778 exports.UnmodifiableMapView$ = UnmodifiableMapView$; | |
| 4779 exports.Maps = Maps; | |
| 4780 exports.Queue = Queue; | |
| 4781 exports.Queue$ = Queue$; | |
| 4782 exports.DoubleLinkedQueueEntry = DoubleLinkedQueueEntry; | |
| 4783 exports.DoubleLinkedQueueEntry$ = DoubleLinkedQueueEntry$; | |
| 4784 exports.DoubleLinkedQueue = DoubleLinkedQueue; | |
| 4785 exports.DoubleLinkedQueue$ = DoubleLinkedQueue$; | |
| 4786 exports.ListQueue = ListQueue; | |
| 4787 exports.ListQueue$ = ListQueue$; | |
| 4788 exports.SetMixin = SetMixin; | |
| 4789 exports.SetMixin$ = SetMixin$; | |
| 4790 exports.SetBase = SetBase; | |
| 4791 exports.SetBase$ = SetBase$; | |
| 4792 exports.SplayTreeMap = SplayTreeMap; | |
| 4793 exports.SplayTreeMap$ = SplayTreeMap$; | |
| 4794 exports.SplayTreeSet = SplayTreeSet; | |
| 4795 exports.SplayTreeSet$ = SplayTreeSet$; | |
| 4796 })(collection || (collection = {})); | |
| OLD | NEW |