| 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 "collection.dart"; | 5 part of "collection.dart"; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A specialized double-linked list of elements that extends [LinkedListEntry]. | 8 * A specialized double-linked list of elements that extends [LinkedListEntry]. |
| 9 * | 9 * |
| 10 * Deprecated. Use the same named class from package `collection`, instead. |
| 11 * [https://pub.dartlang.org/packages/collection] |
| 12 * |
| 10 * This is not a generic data structure. It only accepts elements that extend | 13 * This is not a generic data structure. It only accepts elements that extend |
| 11 * the [LinkedListEntry] class. See the [Queue] implementations for | 14 * the [LinkedListEntry] class. See the [Queue] implementations for |
| 12 * generic collections that allow constant time adding and removing at the ends. | 15 * generic collections that allow constant time adding and removing at the ends. |
| 13 * | 16 * |
| 14 * This is not a [List] implementation. Despite its name, this class does not | 17 * This is not a [List] implementation. Despite its name, this class does not |
| 15 * implement the [List] interface. It does not allow constant time lookup by | 18 * implement the [List] interface. It does not allow constant time lookup by |
| 16 * index. | 19 * index. |
| 17 * | 20 * |
| 18 * Because the elements themselves contain the links of this linked list, | 21 * Because the elements themselves contain the links of this linked list, |
| 19 * each element can be in only one list at a time. To add an element to another | 22 * each element can be in only one list at a time. To add an element to another |
| 20 * list, it must first be removed from its current list (if any). | 23 * list, it must first be removed from its current list (if any). |
| 21 * | 24 * |
| 22 * In return, each element knows its own place in the linked list, as well as | 25 * In return, each element knows its own place in the linked list, as well as |
| 23 * which list it is in. This allows constant time [LinkedListEntry.insertAfter], | 26 * which list it is in. This allows constant time [LinkedListEntry.insertAfter], |
| 24 * [LinkedListEntry.insertBefore] and [LinkedListEntry.unlink] operations | 27 * [LinkedListEntry.insertBefore] and [LinkedListEntry.unlink] operations |
| 25 * when all you have is the element. | 28 * when all you have is the element. |
| 26 * | 29 * |
| 27 * A `LinkedList` also allows constant time adding and removing at either end, | 30 * A `LinkedList` also allows constant time adding and removing at either end, |
| 28 * and a constant time length getter. | 31 * and a constant time length getter. |
| 29 */ | 32 */ |
| 33 @deprecated |
| 30 class LinkedList<E extends LinkedListEntry<E>> extends Iterable<E> { | 34 class LinkedList<E extends LinkedListEntry<E>> extends Iterable<E> { |
| 31 int _modificationCount = 0; | 35 int _modificationCount = 0; |
| 32 int _length = 0; | 36 int _length = 0; |
| 33 E _first; | 37 E _first; |
| 34 | 38 |
| 35 /** | 39 /** |
| 36 * Construct a new empty linked list. | 40 * Construct a new empty linked list. |
| 37 */ | 41 */ |
| 38 LinkedList(); | 42 LinkedList(); |
| 39 | 43 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 _visitedFirst = true; | 214 _visitedFirst = true; |
| 211 _current = _next; | 215 _current = _next; |
| 212 _next = _next._next; | 216 _next = _next._next; |
| 213 return true; | 217 return true; |
| 214 } | 218 } |
| 215 } | 219 } |
| 216 | 220 |
| 217 /** | 221 /** |
| 218 * An object that can be an element in a [LinkedList]. | 222 * An object that can be an element in a [LinkedList]. |
| 219 * | 223 * |
| 224 * Deprecated. Use the same named class from package `collection`, instead. |
| 225 * [https://pub.dartlang.org/packages/collection] |
| 226 * |
| 220 * All elements of a `LinkedList` must extend this class. | 227 * All elements of a `LinkedList` must extend this class. |
| 221 * The class provides the internal links that link elements together | 228 * The class provides the internal links that link elements together |
| 222 * in the `LinkedList`, and a reference to the linked list itself | 229 * in the `LinkedList`, and a reference to the linked list itself |
| 223 * that an element is currently part of. | 230 * that an element is currently part of. |
| 224 * | 231 * |
| 225 * An entry can be in at most one linked list at a time. | 232 * An entry can be in at most one linked list at a time. |
| 226 * While an entry is in a linked list, the [list] property points to that | 233 * While an entry is in a linked list, the [list] property points to that |
| 227 * linked list, and otherwise the `list` property is `null`. | 234 * linked list, and otherwise the `list` property is `null`. |
| 228 * | 235 * |
| 229 * When created, an entry is not in any linked list. | 236 * When created, an entry is not in any linked list. |
| 230 */ | 237 */ |
| 238 @deprecated |
| 231 abstract class LinkedListEntry<E extends LinkedListEntry<E>> { | 239 abstract class LinkedListEntry<E extends LinkedListEntry<E>> { |
| 232 LinkedList<E> _list; | 240 LinkedList<E> _list; |
| 233 E _next; | 241 E _next; |
| 234 E _previous; | 242 E _previous; |
| 235 | 243 |
| 236 /** | 244 /** |
| 237 * Get the linked list containing this element. | 245 * Get the linked list containing this element. |
| 238 * | 246 * |
| 239 * Returns `null` if this entry is not currently in any list. | 247 * Returns `null` if this entry is not currently in any list. |
| 240 */ | 248 */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 /** | 292 /** |
| 285 * Insert an element before this element in this element's linked list. | 293 * Insert an element before this element in this element's linked list. |
| 286 * | 294 * |
| 287 * This entry must be in a linked list when this method is called. | 295 * This entry must be in a linked list when this method is called. |
| 288 * The [entry] must not be in a linked list. | 296 * The [entry] must not be in a linked list. |
| 289 */ | 297 */ |
| 290 void insertBefore(E entry) { | 298 void insertBefore(E entry) { |
| 291 _list._insertBefore(this as dynamic/*=E*/, entry, updateFirst: true); | 299 _list._insertBefore(this as dynamic/*=E*/, entry, updateFirst: true); |
| 292 } | 300 } |
| 293 } | 301 } |
| OLD | NEW |