OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // VMOptions=--enable_checked_mode | 4 // VMOptions=--enable_checked_mode |
5 | 5 |
6 abstract class Link<T> extends Iterable<T> { | 6 import "dart:collection"; |
| 7 |
| 8 abstract class Link<T> extends IterableBase<T> { |
7 factory Link(T head, [Link<T> tail]) = LinkEntry<T>; | 9 factory Link(T head, [Link<T> tail]) = LinkEntry<T>; |
8 Link<T> prepend(T element); | 10 Link<T> prepend(T element); |
9 } | 11 } |
10 | 12 |
11 abstract class EmptyLink<T> extends Link<T> { | 13 abstract class EmptyLink<T> extends Link<T> { |
12 const factory EmptyLink() = LinkTail<T>; | 14 const factory EmptyLink() = LinkTail<T>; |
13 } | 15 } |
14 | 16 |
15 class AbstractLink<T> implements Link<T> { | 17 class AbstractLink<T> implements Link<T> { |
16 const AbstractLink(); | 18 const AbstractLink(); |
(...skipping 18 matching lines...) Expand all Loading... |
35 Link<Fisk> nodes = const EmptyLink<Fisk>(); | 37 Link<Fisk> nodes = const EmptyLink<Fisk>(); |
36 final int id; | 38 final int id; |
37 Fisk(this.id); | 39 Fisk(this.id); |
38 toString() => id.toString(); | 40 toString() => id.toString(); |
39 } | 41 } |
40 | 42 |
41 main() { | 43 main() { |
42 new Fisk(0).nodes.prepend(new Fisk(1)).prepend(new Fisk(2)); | 44 new Fisk(0).nodes.prepend(new Fisk(1)).prepend(new Fisk(2)); |
43 } | 45 } |
44 | 46 |
OLD | NEW |