| 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 org_dartlang_compiler_util; | 5 part of org_dartlang_compiler_util; |
| 6 | 6 |
| 7 class Link<T> implements Iterable<T> { | 7 class Link<T> implements Iterable<T> { |
| 8 T get head => null; | 8 T get head => null; |
| 9 Link<T> get tail => null; | 9 Link<T> get tail => null; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 Link link = new Link<T>(); | 23 Link link = new Link<T>(); |
| 24 for (int i = list.length ; i > 0; i--) { | 24 for (int i = list.length ; i > 0; i--) { |
| 25 link = link.prepend(list[i - 1]); | 25 link = link.prepend(list[i - 1]); |
| 26 } | 26 } |
| 27 return link; | 27 return link; |
| 28 } | 28 } |
| 29 | 29 |
| 30 const Link(); | 30 const Link(); |
| 31 | 31 |
| 32 Link<T> prepend(T element) { | 32 Link<T> prepend(T element) { |
| 33 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM. | |
| 34 return new LinkEntry<T>(element, this); | 33 return new LinkEntry<T>(element, this); |
| 35 } | 34 } |
| 36 | 35 |
| 37 Iterator<T> iterator() => new LinkIterator<T>(this); | 36 Iterator<T> iterator() => new LinkIterator<T>(this); |
| 38 | 37 |
| 39 void printOn(StringBuffer buffer, [separatedBy]) { | 38 void printOn(StringBuffer buffer, [separatedBy]) { |
| 40 } | 39 } |
| 41 | 40 |
| 42 List toList() => new List<T>(0); | 41 List toList() => new List<T>(0); |
| 43 | 42 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 61 } | 60 } |
| 62 | 61 |
| 63 interface LinkBuilder<T> default LinkBuilderImplementation<T> { | 62 interface LinkBuilder<T> default LinkBuilderImplementation<T> { |
| 64 LinkBuilder(); | 63 LinkBuilder(); |
| 65 | 64 |
| 66 Link<T> toLink(); | 65 Link<T> toLink(); |
| 67 void addLast(T t); | 66 void addLast(T t); |
| 68 | 67 |
| 69 final int length; | 68 final int length; |
| 70 } | 69 } |
| OLD | NEW |