| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 util_implementation; | 5 part of util_implementation; |
| 6 | 6 |
| 7 class LinkIterator<T> implements Iterator<T> { | 7 class LinkIterator<T> implements Iterator<T> { |
| 8 T _current; | 8 T _current; |
| 9 Link<T> _link; | 9 Link<T> _link; |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 Link<T> myElements = this; | 100 Link<T> myElements = this; |
| 101 while (!myElements.isEmpty && !other.isEmpty) { | 101 while (!myElements.isEmpty && !other.isEmpty) { |
| 102 if (myElements.head != other.head) { | 102 if (myElements.head != other.head) { |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 myElements = myElements.tail; | 105 myElements = myElements.tail; |
| 106 other = other.tail; | 106 other = other.tail; |
| 107 } | 107 } |
| 108 return myElements.isEmpty && other.isEmpty; | 108 return myElements.isEmpty && other.isEmpty; |
| 109 } | 109 } |
| 110 |
| 111 int slowLength() => 1 + tail.slowLength(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 class LinkBuilderImplementation<T> implements LinkBuilder<T> { | 114 class LinkBuilderImplementation<T> implements LinkBuilder<T> { |
| 113 LinkEntry<T> head = null; | 115 LinkEntry<T> head = null; |
| 114 LinkEntry<T> lastLink = null; | 116 LinkEntry<T> lastLink = null; |
| 115 int length = 0; | 117 int length = 0; |
| 116 | 118 |
| 117 LinkBuilderImplementation(); | 119 LinkBuilderImplementation(); |
| 118 | 120 |
| 119 Link<T> toLink() { | 121 Link<T> toLink() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 if (head == null) { | 133 if (head == null) { |
| 132 head = entry; | 134 head = entry; |
| 133 } else { | 135 } else { |
| 134 lastLink.tail = entry; | 136 lastLink.tail = entry; |
| 135 } | 137 } |
| 136 lastLink = entry; | 138 lastLink = entry; |
| 137 } | 139 } |
| 138 | 140 |
| 139 bool get isEmpty => length == 0; | 141 bool get isEmpty => length == 0; |
| 140 } | 142 } |
| OLD | NEW |