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

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

Issue 744023002: Add Link.copyWithout. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/util/link_implementation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 => throw new StateError("no elements"); 8 T get head => throw new StateError("no elements");
9 Link<T> get tail => null; 9 Link<T> get tail => null;
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 /// Returns true if f returns true for all elements of this list. 121 /// Returns true if f returns true for all elements of this list.
122 /// 122 ///
123 /// Returns true for the empty list. 123 /// Returns true for the empty list.
124 bool every(bool f(T)) { 124 bool every(bool f(T)) {
125 for (Link<T> link = this; !link.isEmpty; link = link.tail){ 125 for (Link<T> link = this; !link.isEmpty; link = link.tail){
126 if (!f(link.head)) return false; 126 if (!f(link.head)) return false;
127 } 127 }
128 return true; 128 return true;
129 } 129 }
130
131 Link copyWithout(e) => this;
130 } 132 }
131 133
132 abstract class LinkBuilder<T> { 134 abstract class LinkBuilder<T> {
133 factory LinkBuilder() = LinkBuilderImplementation; 135 factory LinkBuilder() = LinkBuilderImplementation;
134 136
135 /** 137 /**
136 * Prepends all elements added to the builder to [tail]. The resulting list is 138 * Prepends all elements added to the builder to [tail]. The resulting list is
137 * returned and the builder is cleared. 139 * returned and the builder is cleared.
138 */ 140 */
139 Link<T> toLink([Link<T> tail = const Link()]); 141 Link<T> toLink([Link<T> tail = const Link()]);
140 142
141 List<T> toList(); 143 List<T> toList();
142 144
143 void addLast(T t); 145 void addLast(T t);
144 146
145 final int length; 147 final int length;
146 final bool isEmpty; 148 final bool isEmpty;
147 } 149 }
OLDNEW
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/util/link_implementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698