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 class LinkIterator<T> implements Iterator<T> { | 5 class LinkIterator<T> implements Iterator<T> { |
6 Link<T> current; | 6 Link<T> current; |
7 LinkIterator(Link<T> this.current); | 7 LinkIterator(Link<T> this.current); |
8 bool hasNext() => !current.isEmpty(); | 8 bool get hasNext => !current.isEmpty(); |
9 T next() { | 9 T next() { |
10 T result = current.head; | 10 T result = current.head; |
11 current = current.tail; | 11 current = current.tail; |
12 return result; | 12 return result; |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 class LinkEntry<T> extends Link<T> { | 16 class LinkEntry<T> extends Link<T> { |
17 final T head; | 17 final T head; |
18 Link<T> tail; | 18 Link<T> tail; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 length++; | 109 length++; |
110 LinkEntry<T> entry = new LinkEntry<T>(t, null); | 110 LinkEntry<T> entry = new LinkEntry<T>(t, null); |
111 if (head == null) { | 111 if (head == null) { |
112 head = entry; | 112 head = entry; |
113 } else { | 113 } else { |
114 lastLink.tail = entry; | 114 lastLink.tail = entry; |
115 } | 115 } |
116 lastLink = entry; | 116 lastLink = entry; |
117 } | 117 } |
118 } | 118 } |
OLD | NEW |