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

Side by Side Diff: corelib/src/implementation/queue.dart

Issue 9431015: Wrote functions to convert collections and maps to strings and invoked (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « corelib/src/implementation/maps.dart ('k') | corelib/src/implementation/splay_tree.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) 2012, 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 5
6 /** 6 /**
7 * An entry in a doubly linked list. It contains a pointer to the next 7 * An entry in a doubly linked list. It contains a pointer to the next
8 * entry, the previous entry, and the boxed element. 8 * entry, the previous entry, and the boxed element.
9 */ 9 */
10 class DoubleLinkedQueueEntry<E> { 10 class DoubleLinkedQueueEntry<E> {
11 DoubleLinkedQueueEntry<E> _previous; 11 DoubleLinkedQueueEntry<E> _previous;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DoubleLinkedQueueEntry<E> nextEntry = entry._next; 224 DoubleLinkedQueueEntry<E> nextEntry = entry._next;
225 if (f(entry._element)) other.addLast(entry._element); 225 if (f(entry._element)) other.addLast(entry._element);
226 entry = nextEntry; 226 entry = nextEntry;
227 } 227 }
228 return other; 228 return other;
229 } 229 }
230 230
231 _DoubleLinkedQueueIterator<E> iterator() { 231 _DoubleLinkedQueueIterator<E> iterator() {
232 return new _DoubleLinkedQueueIterator<E>(_sentinel); 232 return new _DoubleLinkedQueueIterator<E>(_sentinel);
233 } 233 }
234
235 String toString() {
236 return Collections.collectionToString(this);
237 }
234 } 238 }
235 239
236 class _DoubleLinkedQueueIterator<E> implements Iterator<E> { 240 class _DoubleLinkedQueueIterator<E> implements Iterator<E> {
237 final _DoubleLinkedQueueEntrySentinel<E> _sentinel; 241 final _DoubleLinkedQueueEntrySentinel<E> _sentinel;
238 DoubleLinkedQueueEntry<E> _currentEntry; 242 DoubleLinkedQueueEntry<E> _currentEntry;
239 243
240 _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel this._sentinel) { 244 _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel this._sentinel) {
241 _currentEntry = _sentinel; 245 _currentEntry = _sentinel;
242 } 246 }
243 247
244 bool hasNext() { 248 bool hasNext() {
245 return _currentEntry._next !== _sentinel; 249 return _currentEntry._next !== _sentinel;
246 } 250 }
247 251
248 E next() { 252 E next() {
249 if (!hasNext()) { 253 if (!hasNext()) {
250 throw const NoMoreElementsException(); 254 throw const NoMoreElementsException();
251 } 255 }
252 _currentEntry = _currentEntry._next; 256 _currentEntry = _currentEntry._next;
253 return _currentEntry.element; 257 return _currentEntry.element;
254 } 258 }
255 } 259 }
OLDNEW
« no previous file with comments | « corelib/src/implementation/maps.dart ('k') | corelib/src/implementation/splay_tree.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698