| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 myElements = myElements.tail; | 130 myElements = myElements.tail; |
| 131 other = other.tail; | 131 other = other.tail; |
| 132 } | 132 } |
| 133 return myElements.isEmpty && other.isEmpty; | 133 return myElements.isEmpty && other.isEmpty; |
| 134 } | 134 } |
| 135 | 135 |
| 136 int get hashCode => throw new UnsupportedError('LinkEntry.hashCode'); | 136 int get hashCode => throw new UnsupportedError('LinkEntry.hashCode'); |
| 137 | 137 |
| 138 int slowLength() => 1 + tail.slowLength(); | 138 int slowLength() => 1 + tail.slowLength(); |
| 139 |
| 140 Link copyWithout(e) { |
| 141 LinkBuilder copy = new LinkBuilder(); |
| 142 Link link = this; |
| 143 for (; !link.isEmpty; link = link.tail) { |
| 144 if (link.head != e) { |
| 145 copy.addLast(link.head); |
| 146 } |
| 147 } |
| 148 return copy.toLink(link); |
| 149 } |
| 139 } | 150 } |
| 140 | 151 |
| 141 class LinkBuilderImplementation<T> implements LinkBuilder<T> { | 152 class LinkBuilderImplementation<T> implements LinkBuilder<T> { |
| 142 LinkEntry<T> head = null; | 153 LinkEntry<T> head = null; |
| 143 LinkEntry<T> lastLink = null; | 154 LinkEntry<T> lastLink = null; |
| 144 int length = 0; | 155 int length = 0; |
| 145 | 156 |
| 146 LinkBuilderImplementation(); | 157 LinkBuilderImplementation(); |
| 147 | 158 |
| 148 Link<T> toLink([Link<T> tail = const Link()]) { | 159 Link<T> toLink([Link<T> tail = const Link()]) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 175 if (head == null) { | 186 if (head == null) { |
| 176 head = entry; | 187 head = entry; |
| 177 } else { | 188 } else { |
| 178 lastLink.tail = entry; | 189 lastLink.tail = entry; |
| 179 } | 190 } |
| 180 lastLink = entry; | 191 lastLink = entry; |
| 181 } | 192 } |
| 182 | 193 |
| 183 bool get isEmpty => length == 0; | 194 bool get isEmpty => length == 0; |
| 184 } | 195 } |
| OLD | NEW |