| OLD | NEW |
| 1 part of dart.collection; | 1 part of dart.collection; |
| 2 abstract class Queue<E> implements Iterable<E>, EfficientLength {factory Queue(
) = ListQueue<E>; | 2 abstract class Queue<E> implements Iterable<E>, EfficientLength {factory Queue(
) = ListQueue<E>; |
| 3 factory Queue.from(Iterable elements) = ListQueue<E>.from; | 3 factory Queue.from(Iterable elements) = ListQueue<E>.from; |
| 4 E removeFirst(); | 4 E removeFirst(); |
| 5 E removeLast(); | 5 E removeLast(); |
| 6 void addFirst(E value); | 6 void addFirst(E value); |
| 7 void addLast(E value); | 7 void addLast(E value); |
| 8 void add(E value); | 8 void add(E value); |
| 9 bool remove(Object object); | 9 bool remove(Object object); |
| 10 void addAll(Iterable<E> iterable); | 10 void addAll(Iterable<E> iterable); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 ListQueue<E> result = new ListQueue<E>(capacity); | 238 ListQueue<E> result = new ListQueue<E>(capacity); |
| 239 for (final E element in elements) { | 239 for (final E element in elements) { |
| 240 result.addLast(element); | 240 result.addLast(element); |
| 241 } | 241 } |
| 242 return result; | 242 return result; |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 Iterator<E> get iterator => new _ListQueueIterator<E>(this); | 245 Iterator<E> get iterator => new _ListQueueIterator<E>(this); |
| 246 void forEach(void action(E element)) { | 246 void forEach(void action(E element)) { |
| 247 int modificationCount = _modificationCount; | 247 int modificationCount = _modificationCount; |
| 248 for (int i = _head; | 248 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { |
| 249 i != _tail; | |
| 250 i = (i + 1) & (_table.length - 1)) { | |
| 251 action(_table[i]); | 249 action(_table[i]); |
| 252 _checkModification(modificationCount); | 250 _checkModification(modificationCount); |
| 253 } | 251 } |
| 254 } | 252 } |
| 255 bool get isEmpty => _head == _tail; | 253 bool get isEmpty => _head == _tail; |
| 256 int get length => (_tail - _head) & (_table.length - 1); | 254 int get length => (_tail - _head) & (_table.length - 1); |
| 257 E get first { | 255 E get first { |
| 258 if (_head == _tail) throw IterableElementError.noElement(); | 256 if (_head == _tail) throw IterableElementError.noElement(); |
| 259 return _table[_head]; | 257 return _table[_head]; |
| 260 } | 258 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 _tail = preSpace; | 328 _tail = preSpace; |
| 331 } | 329 } |
| 332 } | 330 } |
| 333 _modificationCount++; | 331 _modificationCount++; |
| 334 } | 332 } |
| 335 else { | 333 else { |
| 336 for (E element in elements) _add(element); | 334 for (E element in elements) _add(element); |
| 337 } | 335 } |
| 338 } | 336 } |
| 339 bool remove(Object object) { | 337 bool remove(Object object) { |
| 340 for (int i = _head; | 338 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { |
| 341 i != _tail; | |
| 342 i = (i + 1) & (_table.length - 1)) { | |
| 343 E element = _table[i]; | 339 E element = _table[i]; |
| 344 if (element == object) { | 340 if (element == object) { |
| 345 _remove(i); | 341 _remove(i); |
| 346 _modificationCount++; | 342 _modificationCount++; |
| 347 return true; | 343 return true; |
| 348 } | 344 } |
| 349 } | 345 } |
| 350 return false; | 346 return false; |
| 351 } | 347 } |
| 352 void _filterWhere(bool test(E element), bool removeMatching) { | 348 void _filterWhere(bool test(E element), bool removeMatching) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 367 } | 363 } |
| 368 } | 364 } |
| 369 void removeWhere(bool test(E element)) { | 365 void removeWhere(bool test(E element)) { |
| 370 _filterWhere(test, true); | 366 _filterWhere(test, true); |
| 371 } | 367 } |
| 372 void retainWhere(bool test(E element)) { | 368 void retainWhere(bool test(E element)) { |
| 373 _filterWhere(test, false); | 369 _filterWhere(test, false); |
| 374 } | 370 } |
| 375 void clear() { | 371 void clear() { |
| 376 if (_head != _tail) { | 372 if (_head != _tail) { |
| 377 for (int i = _head; | 373 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { |
| 378 i != _tail; | |
| 379 i = (i + 1) & (_table.length - 1)) { | |
| 380 _table[i] = ((__x36) => DDC$RT.cast(__x36, Null, E, "CastLiteral", """line 553,
column 21 of dart:collection/queue.dart: """, __x36 is E, false))(null); | 374 _table[i] = ((__x36) => DDC$RT.cast(__x36, Null, E, "CastLiteral", """line 553,
column 21 of dart:collection/queue.dart: """, __x36 is E, false))(null); |
| 381 } | 375 } |
| 382 _head = _tail = 0; | 376 _head = _tail = 0; |
| 383 _modificationCount++; | 377 _modificationCount++; |
| 384 } | 378 } |
| 385 } | 379 } |
| 386 String toString() => IterableBase.iterableToFullString(this, "{", "}"); | 380 String toString() => IterableBase.iterableToFullString(this, "{", "}"); |
| 387 void addLast(E element) { | 381 void addLast(E element) { |
| 388 _add(element); | 382 _add(element); |
| 389 } | 383 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 405 if (_head == _tail) throw IterableElementError.noElement(); | 399 if (_head == _tail) throw IterableElementError.noElement(); |
| 406 _modificationCount++; | 400 _modificationCount++; |
| 407 _tail = (_tail - 1) & (_table.length - 1); | 401 _tail = (_tail - 1) & (_table.length - 1); |
| 408 E result = _table[_tail]; | 402 E result = _table[_tail]; |
| 409 _table[_tail] = ((__x38) => DDC$RT.cast(__x38, Null, E, "CastLiteral", """line
587, column 21 of dart:collection/queue.dart: """, __x38 is E, false))(null); | 403 _table[_tail] = ((__x38) => DDC$RT.cast(__x38, Null, E, "CastLiteral", """line
587, column 21 of dart:collection/queue.dart: """, __x38 is E, false))(null); |
| 410 return result; | 404 return result; |
| 411 } | 405 } |
| 412 static bool _isPowerOf2(int number) => (number & (number - 1)) == 0; | 406 static bool _isPowerOf2(int number) => (number & (number - 1)) == 0; |
| 413 static int _nextPowerOf2(int number) { | 407 static int _nextPowerOf2(int number) { |
| 414 assert (number > 0); number = (number << 1) - 1; | 408 assert (number > 0); number = (number << 1) - 1; |
| 415 for (; | 409 for (;;) { |
| 416 ; | |
| 417 ) { | |
| 418 int nextNumber = number & (number - 1); | 410 int nextNumber = number & (number - 1); |
| 419 if (nextNumber == 0) return number; | 411 if (nextNumber == 0) return number; |
| 420 number = nextNumber; | 412 number = nextNumber; |
| 421 } | 413 } |
| 422 } | 414 } |
| 423 void _checkModification(int expectedModificationCount) { | 415 void _checkModification(int expectedModificationCount) { |
| 424 if (expectedModificationCount != _modificationCount) { | 416 if (expectedModificationCount != _modificationCount) { |
| 425 throw new ConcurrentModificationError(this); | 417 throw new ConcurrentModificationError(this); |
| 426 } | 418 } |
| 427 } | 419 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 _queue._checkModification(_modificationCount); | 492 _queue._checkModification(_modificationCount); |
| 501 if (_position == _end) { | 493 if (_position == _end) { |
| 502 _current = ((__x41) => DDC$RT.cast(__x41, Null, E, "CastLiteral", """line 735, c
olumn 18 of dart:collection/queue.dart: """, __x41 is E, false))(null); | 494 _current = ((__x41) => DDC$RT.cast(__x41, Null, E, "CastLiteral", """line 735, c
olumn 18 of dart:collection/queue.dart: """, __x41 is E, false))(null); |
| 503 return false; | 495 return false; |
| 504 } | 496 } |
| 505 _current = ((__x42) => DDC$RT.cast(__x42, dynamic, E, "CastGeneral", """line 73
8, column 16 of dart:collection/queue.dart: """, __x42 is E, false))(_queue._tab
le[_position]); | 497 _current = ((__x42) => DDC$RT.cast(__x42, dynamic, E, "CastGeneral", """line 73
8, column 16 of dart:collection/queue.dart: """, __x42 is E, false))(_queue._tab
le[_position]); |
| 506 _position = (_position + 1) & (_queue._table.length - 1); | 498 _position = (_position + 1) & (_queue._table.length - 1); |
| 507 return true; | 499 return true; |
| 508 } | 500 } |
| 509 } | 501 } |
| OLD | NEW |