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

Side by Side Diff: sdk/lib/collection/queue.dart

Issue 711003002: Add some ArgumentError and RangeError constructors that capture more information. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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
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 dart.collection; 5 part of dart.collection;
6 6
7 /** 7 /**
8 * A [Queue] is a collection that can be manipulated at both ends. One 8 * A [Queue] is a collection that can be manipulated at both ends. One
9 * can iterate over the elements of a queue through [forEach] or with 9 * can iterate over the elements of a queue through [forEach] or with
10 * an [Iterator]. 10 * an [Iterator].
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return _table[(_tail - 1) & (_table.length - 1)]; 420 return _table[(_tail - 1) & (_table.length - 1)];
421 } 421 }
422 422
423 E get single { 423 E get single {
424 if (_head == _tail) throw IterableElementError.noElement(); 424 if (_head == _tail) throw IterableElementError.noElement();
425 if (length > 1) throw IterableElementError.tooMany(); 425 if (length > 1) throw IterableElementError.tooMany();
426 return _table[_head]; 426 return _table[_head];
427 } 427 }
428 428
429 E elementAt(int index) { 429 E elementAt(int index) {
430 if (index < 0 || index > length) { 430 if (index < 0 || index >= length) {
431 throw new RangeError.range(index, 0, length); 431 throw new RangeError.index(index, this);
432 } 432 }
433 return _table[(_head + index) & (_table.length - 1)]; 433 return _table[(_head + index) & (_table.length - 1)];
434 } 434 }
435 435
436 List<E> toList({ bool growable: true }) { 436 List<E> toList({ bool growable: true }) {
437 List<E> list; 437 List<E> list;
438 if (growable) { 438 if (growable) {
439 list = new List<E>()..length = length; 439 list = new List<E>()..length = length;
440 } else { 440 } else {
441 list = new List<E>(length); 441 list = new List<E>(length);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 _queue._checkModification(_modificationCount); 714 _queue._checkModification(_modificationCount);
715 if (_position == _end) { 715 if (_position == _end) {
716 _current = null; 716 _current = null;
717 return false; 717 return false;
718 } 718 }
719 _current = _queue._table[_position]; 719 _current = _queue._table[_position];
720 _position = (_position + 1) & (_queue._table.length - 1); 720 _position = (_position + 1) & (_queue._table.length - 1);
721 return true; 721 return true;
722 } 722 }
723 } 723 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698