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

Side by Side Diff: dart/pkg/compiler/lib/src/util/link_implementation.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 | « dart/pkg/compiler/lib/src/util/link.dart ('k') | dart/tests/compiler/dart2js/link_test.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 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 myElements = myElements.tail; 130 myElements = myElements.tail;
131 other = other.tail; 131 other = other.tail;
132 } 132 }
133 return myElements.isEmpty && other.isEmpty; 133 return myElements.isEmpty && other.isEmpty;
134 } 134 }
135 135
136 int get hashCode => throw new UnsupportedError('LinkEntry.hashCode'); 136 int get hashCode => throw new UnsupportedError('LinkEntry.hashCode');
137 137
138 int slowLength() => 1 + tail.slowLength(); 138 int slowLength() => 1 + tail.slowLength();
139
140 Link copyWithout(e) {
141 LinkBuilder copy = new LinkBuilder();
142 Link link = this;
143 for (; !link.isEmpty; link = link.tail) {
144 if (link.head != e) {
145 copy.addLast(link.head);
146 }
147 }
148 return copy.toLink(link);
149 }
139 } 150 }
140 151
141 class LinkBuilderImplementation<T> implements LinkBuilder<T> { 152 class LinkBuilderImplementation<T> implements LinkBuilder<T> {
142 LinkEntry<T> head = null; 153 LinkEntry<T> head = null;
143 LinkEntry<T> lastLink = null; 154 LinkEntry<T> lastLink = null;
144 int length = 0; 155 int length = 0;
145 156
146 LinkBuilderImplementation(); 157 LinkBuilderImplementation();
147 158
148 Link<T> toLink([Link<T> tail = const Link()]) { 159 Link<T> toLink([Link<T> tail = const Link()]) {
(...skipping 26 matching lines...) Expand all
175 if (head == null) { 186 if (head == null) {
176 head = entry; 187 head = entry;
177 } else { 188 } else {
178 lastLink.tail = entry; 189 lastLink.tail = entry;
179 } 190 }
180 lastLink = entry; 191 lastLink = entry;
181 } 192 }
182 193
183 bool get isEmpty => length == 0; 194 bool get isEmpty => length == 0;
184 } 195 }
OLDNEW
« no previous file with comments | « dart/pkg/compiler/lib/src/util/link.dart ('k') | dart/tests/compiler/dart2js/link_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698