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

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

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « pkg/compiler/lib/src/util/link.dart ('k') | pkg/compiler/lib/src/util/maplet.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 } 46 }
47 47
48 class MappedLinkIterable<S, T> extends IterableBase<T> { 48 class MappedLinkIterable<S, T> extends IterableBase<T> {
49 Transformation<S, T> _transformation; 49 Transformation<S, T> _transformation;
50 Link<S> _link; 50 Link<S> _link;
51 51
52 MappedLinkIterable(this._link, this._transformation); 52 MappedLinkIterable(this._link, this._transformation);
53 53
54 Iterator<T> get iterator { 54 Iterator<T> get iterator {
55 return new MappedLinkIterator<S,T>(_link, _transformation); 55 return new MappedLinkIterator<S, T>(_link, _transformation);
56 } 56 }
57 } 57 }
58 58
59 class LinkEntry<T> extends Link<T> { 59 class LinkEntry<T> extends Link<T> {
60 final T head; 60 final T head;
61 Link<T> tail; 61 Link<T> tail;
62 62
63 LinkEntry(T this.head, [Link<T> tail]) 63 LinkEntry(T this.head, [Link<T> tail])
64 : this.tail = ((tail == null) ? new Link<T>() : tail); 64 : this.tail = ((tail == null) ? new Link<T>() : tail);
65 65
66 Link<T> prepend(T element) { 66 Link<T> prepend(T element) {
67 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM. 67 // TODO(ahe): Use new Link<T>, but this cost 8% performance on VM.
68 return new LinkEntry<T>(element, this); 68 return new LinkEntry<T>(element, this);
69 } 69 }
70 70
71 void printOn(StringBuffer buffer, [separatedBy]) { 71 void printOn(StringBuffer buffer, [separatedBy]) {
72 buffer.write(head); 72 buffer.write(head);
73 if (separatedBy == null) separatedBy = ''; 73 if (separatedBy == null) separatedBy = '';
74 for (Link link = tail; link.isNotEmpty; link = link.tail) { 74 for (Link link = tail; link.isNotEmpty; link = link.tail) {
(...skipping 21 matching lines...) Expand all
96 Link<T> reversePrependAll(Link<T> from) { 96 Link<T> reversePrependAll(Link<T> from) {
97 Link<T> result; 97 Link<T> result;
98 for (result = this; from.isNotEmpty; from = from.tail) { 98 for (result = this; from.isNotEmpty; from = from.tail) {
99 result = result.prepend(from.head); 99 result = result.prepend(from.head);
100 } 100 }
101 return result; 101 return result;
102 } 102 }
103 103
104 Link<T> skip(int n) { 104 Link<T> skip(int n) {
105 Link<T> link = this; 105 Link<T> link = this;
106 for (int i = 0 ; i < n ; i++) { 106 for (int i = 0; i < n; i++) {
107 if (link.isEmpty) { 107 if (link.isEmpty) {
108 throw new RangeError('Index $n out of range'); 108 throw new RangeError('Index $n out of range');
109 } 109 }
110 link = link.tail; 110 link = link.tail;
111 } 111 }
112 return link; 112 return link;
113 } 113 }
114 114
115 bool get isEmpty => false; 115 bool get isEmpty => false;
116 bool get isNotEmpty => true; 116 bool get isNotEmpty => true;
117 117
118 void forEach(void f(T element)) { 118 void forEach(void f(T element)) {
119 for (Link<T> link = this; link.isNotEmpty; link = link.tail) { 119 for (Link<T> link = this; link.isNotEmpty; link = link.tail) {
120 f(link.head); 120 f(link.head);
121 } 121 }
122 } 122 }
123 123
124 bool operator ==(other) { 124 bool operator ==(other) {
125 if (other is !Link<T>) return false; 125 if (other is! Link<T>) return false;
126 Link<T> myElements = this; 126 Link<T> myElements = this;
127 while (myElements.isNotEmpty && other.isNotEmpty) { 127 while (myElements.isNotEmpty && other.isNotEmpty) {
128 if (myElements.head != other.head) { 128 if (myElements.head != other.head) {
129 return false; 129 return false;
130 } 130 }
131 myElements = myElements.tail; 131 myElements = myElements.tail;
132 other = other.tail; 132 other = other.tail;
133 } 133 }
134 return myElements.isEmpty && other.isEmpty; 134 return myElements.isEmpty && other.isEmpty;
135 } 135 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 throw new StateError("no elements"); 210 throw new StateError("no elements");
211 } 211 }
212 212
213 void clear() { 213 void clear() {
214 head = null; 214 head = null;
215 lastLink = null; 215 lastLink = null;
216 length = 0; 216 length = 0;
217 } 217 }
218 } 218 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/util/link.dart ('k') | pkg/compiler/lib/src/util/maplet.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698