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 Link<T> current; | 8 T _current; |
9 LinkIterator(Link<T> this.current); | 9 Link<T> _link; |
10 bool get hasNext => !current.isEmpty; | 10 |
11 T next() { | 11 LinkIterator(Link<T> this._link); |
12 T result = current.head; | 12 |
13 current = current.tail; | 13 T get current => _current; |
14 return result; | 14 |
| 15 bool moveNext() { |
| 16 if (_link.isEmpty) { |
| 17 _current = null; |
| 18 return false; |
| 19 } |
| 20 _current = _link.head; |
| 21 _link = _link.tail; |
| 22 return true; |
15 } | 23 } |
16 } | 24 } |
17 | 25 |
18 class LinkEntry<T> extends Link<T> { | 26 class LinkEntry<T> extends Link<T> { |
19 final T head; | 27 final T head; |
20 Link<T> tail; | 28 Link<T> tail; |
21 | 29 |
22 LinkEntry(T this.head, [Link<T> tail]) | 30 LinkEntry(T this.head, [Link<T> tail]) |
23 : this.tail = ((tail == null) ? new Link<T>() : tail); | 31 : this.tail = ((tail == null) ? new Link<T>() : tail); |
24 | 32 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (head == null) { | 121 if (head == null) { |
114 head = entry; | 122 head = entry; |
115 } else { | 123 } else { |
116 lastLink.tail = entry; | 124 lastLink.tail = entry; |
117 } | 125 } |
118 lastLink = entry; | 126 lastLink = entry; |
119 } | 127 } |
120 | 128 |
121 bool get isEmpty => length == 0; | 129 bool get isEmpty => length == 0; |
122 } | 130 } |
OLD | NEW |