| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A linked list implementation, providing O(1) removal(unlink) of elements and | 9 * A linked list implementation, providing O(1) removal(unlink) of elements and |
| 10 * manual traversal through [next] and [previous]. | 10 * manual traversal through [next] and [previous]. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * If [entry] is not in the list, `false` is returned. | 54 * If [entry] is not in the list, `false` is returned. |
| 55 */ | 55 */ |
| 56 bool remove(E entry) { | 56 bool remove(E entry) { |
| 57 if (entry._list != this) return false; | 57 if (entry._list != this) return false; |
| 58 _unlink(entry); // Unlink will decrement length. | 58 _unlink(entry); // Unlink will decrement length. |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 Iterator<E> get iterator => new _LinkedListIterator<E>(this); | 62 Iterator<E> get iterator => new _LinkedListIterator<E>(this); |
| 63 | 63 |
| 64 // TODO(zarah) Remove this, and let it be inherited by IterableMixin |
| 65 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}'); |
| 66 |
| 64 int get length => _length; | 67 int get length => _length; |
| 65 | 68 |
| 66 void clear() { | 69 void clear() { |
| 67 _modificationCount++; | 70 _modificationCount++; |
| 68 _LinkedListLink next = _next; | 71 _LinkedListLink next = _next; |
| 69 while (!identical(next, this)) { | 72 while (!identical(next, this)) { |
| 70 E entry = next; | 73 E entry = next; |
| 71 next = entry._next; | 74 next = entry._next; |
| 72 entry._next = entry._previous = entry._list = null; | 75 entry._next = entry._previous = entry._list = null; |
| 73 } | 76 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 _list._insertAfter(this, entry); | 226 _list._insertAfter(this, entry); |
| 224 } | 227 } |
| 225 | 228 |
| 226 /** | 229 /** |
| 227 * Insert an element before this. | 230 * Insert an element before this. |
| 228 */ | 231 */ |
| 229 void insertBefore(E entry) { | 232 void insertBefore(E entry) { |
| 230 _list._insertAfter(_previous, entry); | 233 _list._insertAfter(_previous, entry); |
| 231 } | 234 } |
| 232 } | 235 } |
| OLD | NEW |