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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (link.isEmpty) { | 74 if (link.isEmpty) { |
75 throw new RangeError('Index $n out of range'); | 75 throw new RangeError('Index $n out of range'); |
76 } | 76 } |
77 link = link.tail; | 77 link = link.tail; |
78 } | 78 } |
79 return link; | 79 return link; |
80 } | 80 } |
81 | 81 |
82 bool get isEmpty => false; | 82 bool get isEmpty => false; |
83 | 83 |
84 List<T> toList({ bool growable: false }) { | 84 List<T> toList({ bool growable: true }) { |
85 return new List<T>.from(this, growable: growable); | 85 return new List<T>.from(this, growable: growable); |
86 } | 86 } |
87 | 87 |
88 void forEach(void f(T element)) { | 88 void forEach(void f(T element)) { |
89 for (Link<T> link = this; !link.isEmpty; link = link.tail) { | 89 for (Link<T> link = this; !link.isEmpty; link = link.tail) { |
90 f(link.head); | 90 f(link.head); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 bool operator ==(other) { | 94 bool operator ==(other) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if (head == null) { | 129 if (head == null) { |
130 head = entry; | 130 head = entry; |
131 } else { | 131 } else { |
132 lastLink.tail = entry; | 132 lastLink.tail = entry; |
133 } | 133 } |
134 lastLink = entry; | 134 lastLink = entry; |
135 } | 135 } |
136 | 136 |
137 bool get isEmpty => length == 0; | 137 bool get isEmpty => length == 0; |
138 } | 138 } |
OLD | NEW |