Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/util/link.dart

Issue 177963002: Use List instead of Link in the type system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 dart2js.util; 5 part of dart2js.util;
6 6
7 class Link<T> { 7 class Link<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
11 factory Link.fromList(List<T> list) {
12 switch (list.length) {
13 case 0:
14 return new Link<T>();
15 case 1:
16 return new LinkEntry<T>(list[0]);
17 case 2:
18 return new LinkEntry<T>(list[0], new LinkEntry<T>(list[1]));
19 case 3:
20 return new LinkEntry<T>(
21 list[0], new LinkEntry<T>(list[1], new LinkEntry<T>(list[2])));
22 }
23 Link link = new Link<T>();
24 for (int i = list.length ; i > 0; i--) {
25 link = link.prepend(list[i - 1]);
26 }
27 return link;
28 }
29
30 const Link(); 11 const Link();
31 12
32 Link<T> prepend(T element) { 13 Link<T> prepend(T element) {
33 return new LinkEntry<T>(element, this); 14 return new LinkEntry<T>(element, this);
34 } 15 }
35 16
36 Iterator<T> get iterator => new LinkIterator<T>(this); 17 Iterator<T> get iterator => new LinkIterator<T>(this);
37 18
38 void printOn(StringBuffer buffer, [separatedBy]) { 19 void printOn(StringBuffer buffer, [separatedBy]) {
39 } 20 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 */ 138 */
158 Link<T> toLink([Link<T> tail = const Link()]); 139 Link<T> toLink([Link<T> tail = const Link()]);
159 140
160 List<T> toList(); 141 List<T> toList();
161 142
162 void addLast(T t); 143 void addLast(T t);
163 144
164 final int length; 145 final int length;
165 final bool isEmpty; 146 final bool isEmpty;
166 } 147 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/typechecker.dart ('k') | sdk/lib/_internal/compiler/implementation/util/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698