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

Side by Side Diff: pkg/compiler/lib/src/util/link_implementation.dart

Issue 1302333006: Support metadata on patches. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove partial renaming Created 5 years, 3 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
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 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 int length = 0; 162 int length = 0;
163 163
164 LinkBuilderImplementation(); 164 LinkBuilderImplementation();
165 165
166 Link<T> toLink([Link<T> tail = const Link()]) { 166 Link<T> toLink([Link<T> tail = const Link()]) {
167 if (head == null) return tail; 167 if (head == null) return tail;
168 lastLink.tail = tail; 168 lastLink.tail = tail;
169 Link<T> link = head; 169 Link<T> link = head;
170 lastLink = null; 170 lastLink = null;
171 head = null; 171 head = null;
172 length = 0;
172 return link; 173 return link;
173 } 174 }
174 175
175 List<T> toList() { 176 List<T> toList() {
176 if (length == 0) return new List<T>(0); 177 if (length == 0) return new List<T>(0);
177 List<T> list = new List<T>(length); 178 List<T> list = new List<T>(length);
178 int index = 0; 179 int index = 0;
179 Link<T> link = head; 180 Link<T> link = head;
180 while (link.isNotEmpty) { 181 while (link.isNotEmpty) {
181 list[index] = link.head; 182 list[index] = link.head;
182 link = link.tail; 183 link = link.tail;
183 index++; 184 index++;
184 } 185 }
185 lastLink = null; 186 lastLink = null;
186 head = null; 187 head = null;
188 length = 0;
187 return list; 189 return list;
188 } 190 }
189 191
190 Link<T> addLast(T t) { 192 Link<T> addLast(T t) {
191 length++; 193 length++;
192 LinkEntry<T> entry = new LinkEntry<T>(t, null); 194 LinkEntry<T> entry = new LinkEntry<T>(t, null);
193 if (head == null) { 195 if (head == null) {
194 head = entry; 196 head = entry;
195 } else { 197 } else {
196 lastLink.tail = entry; 198 lastLink.tail = entry;
197 } 199 }
198 lastLink = entry; 200 lastLink = entry;
199 return entry; 201 return entry;
200 } 202 }
201 203
202 bool get isEmpty => length == 0; 204 bool get isEmpty => length == 0;
205
206 T get first {
207 if (head != null) {
208 return head.head;
209 }
210 throw new StateError("no elements");
211 }
212
213 void clear() {
214 head = null;
215 lastLink = null;
216 length = 0;
217 }
203 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698