| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 Iterator<T> get iterator { | 54 Iterator<T> get iterator { |
| 55 return new MappedLinkIterator<S, T>(_link, _transformation); | 55 return new MappedLinkIterator<S, T>(_link, _transformation); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 class LinkEntry<T> extends Link<T> { | 59 class LinkEntry<T> extends Link<T> { |
| 60 final T head; | 60 final T head; |
| 61 Link<T> tail; | 61 Link<T> tail; |
| 62 | 62 |
| 63 LinkEntry(T this.head, [Link<T> tail]) | 63 LinkEntry(T this.head, [Link<T> tail]) |
| 64 : this.tail = ((tail == null) ? new Link<T>() : tail); | 64 : this.tail = ((tail == null) ? const Link() : tail); |
| 65 | 65 |
| 66 Link<T> prepend(T element) { | 66 Link<T> prepend(T element) { |
| 67 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM. | 67 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM. |
| 68 return new LinkEntry<T>(element, this); | 68 return new LinkEntry<T>(element, this); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void printOn(StringBuffer buffer, [separatedBy]) { | 71 void printOn(StringBuffer buffer, [separatedBy]) { |
| 72 buffer.write(head); | 72 buffer.write(head); |
| 73 if (separatedBy == null) separatedBy = ''; | 73 if (separatedBy == null) separatedBy = ''; |
| 74 for (Link link = tail; link.isNotEmpty; link = link.tail) { | 74 for (Link link = tail; link.isNotEmpty; link = link.tail) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 209 } |
| 210 throw new StateError("no elements"); | 210 throw new StateError("no elements"); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void clear() { | 213 void clear() { |
| 214 head = null; | 214 head = null; |
| 215 lastLink = null; | 215 lastLink = null; |
| 216 length = 0; | 216 length = 0; |
| 217 } | 217 } |
| 218 } | 218 } |
| OLD | NEW |