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

Unified Diff: packages/collection/lib/src/queue_list.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/collection/lib/src/priority_queue.dart ('k') | packages/collection/lib/src/typed_wrappers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/collection/lib/src/queue_list.dart
diff --git a/packages/collection/lib/src/queue_list.dart b/packages/collection/lib/src/queue_list.dart
index 0ef888f9c1fb9f666f8463e5d4c0b2925b2e0803..73c1f66e95d2e461f9b4016396542426bc8600f8 100644
--- a/packages/collection/lib/src/queue_list.dart
+++ b/packages/collection/lib/src/queue_list.dart
@@ -4,9 +4,7 @@
import 'dart:collection';
-/**
- * A class that efficiently implements both [Queue] and [List].
- */
+/// A class that efficiently implements both [Queue] and [List].
// TODO(nweiz): Currently this code is copied almost verbatim from
// dart:collection. The only changes are to implement List and to remove methods
// that are redundant with ListMixin. Remove or simplify it when issue 21330 is
@@ -17,13 +15,13 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
int _head;
int _tail;
- /**
- * Create an empty queue.
- *
- * If [initialCapacity] is given, prepare the queue for at least that many
- * elements.
- */
- QueueList([int initialCapacity]) : _head = 0, _tail = 0 {
+ /// Create an empty queue.
+ ///
+ /// If [initialCapacity] is given, prepare the queue for at least that many
+ /// elements.
+ QueueList([int initialCapacity])
+ : _head = 0,
+ _tail = 0 {
if (initialCapacity == null || initialCapacity < _INITIAL_CAPACITY) {
initialCapacity = _INITIAL_CAPACITY;
} else if (!_isPowerOf2(initialCapacity)) {
@@ -33,15 +31,13 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
_table = new List<E>(initialCapacity);
}
- /**
- * Create a queue initially containing the elements of [source].
- */
+ /// Create a queue initially containing the elements of [source].
factory QueueList.from(Iterable<E> source) {
if (source is List) {
int length = source.length;
QueueList<E> queue = new QueueList(length + 1);
assert(queue._table.length > length);
- List sourceList = source;
+ var sourceList = source;
queue._table.setRange(0, length, sourceList, 0);
queue._tail = length;
return queue;
@@ -58,7 +54,7 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
void addAll(Iterable<E> elements) {
if (elements is List) {
- List list = elements;
+ var list = elements;
int addCount = list.length;
int length = this.length;
if (length + addCount >= _table.length) {
@@ -88,7 +84,9 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
// Queue interface.
- void addLast(E element) { _add(element); }
+ void addLast(E element) {
+ _add(element);
+ }
void addFirst(E element) {
_head = (_head - 1) & (_table.length - 1);
@@ -131,7 +129,7 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
int newTail = _tail + delta; // [delta] is negative.
if (newTail >= 0) {
_table.fillRange(newTail, _tail, null);
- } else {
+ } else {
newTail += _table.length;
_table.fillRange(0, _tail, null);
_table.fillRange(newTail, _table.length, null);
@@ -147,7 +145,7 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
return _table[(_head + index) & (_table.length - 1)];
}
- void operator[]=(int index, E value) {
+ void operator []=(int index, E value) {
if (index < 0 || index >= length) {
throw new RangeError("Index $index must be in the range [0..$length).");
}
@@ -157,40 +155,34 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
// Internal helper functions.
- /**
- * Whether [number] is a power of two.
- *
- * Only works for positive numbers.
- */
+ /// Whether [number] is a power of two.
+ ///
+ /// Only works for positive numbers.
static bool _isPowerOf2(int number) => (number & (number - 1)) == 0;
- /**
- * Rounds [number] up to the nearest power of 2.
- *
- * If [number] is a power of 2 already, it is returned.
- *
- * Only works for positive numbers.
- */
+ /// Rounds [number] up to the nearest power of 2.
+ ///
+ /// If [number] is a power of 2 already, it is returned.
+ ///
+ /// Only works for positive numbers.
static int _nextPowerOf2(int number) {
assert(number > 0);
number = (number << 1) - 1;
- for(;;) {
+ for (;;) {
int nextNumber = number & (number - 1);
if (nextNumber == 0) return number;
number = nextNumber;
}
}
- /** Adds element at end of queue. Used by both [add] and [addAll]. */
+ /// Adds element at end of queue. Used by both [add] and [addAll].
void _add(E element) {
_table[_tail] = element;
_tail = (_tail + 1) & (_table.length - 1);
if (_head == _tail) _grow();
}
- /**
- * Grow the table when full.
- */
+ /// Grow the table when full.
void _grow() {
List<E> newTable = new List<E>(_table.length * 2);
int split = _table.length - _head;
@@ -215,7 +207,7 @@ class QueueList<E> extends Object with ListMixin<E> implements Queue<E> {
}
}
- /** Grows the table even if it is not full. */
+ /// Grows the table even if it is not full.
void _preGrow(int newElementCount) {
assert(newElementCount >= length);
« no previous file with comments | « packages/collection/lib/src/priority_queue.dart ('k') | packages/collection/lib/src/typed_wrappers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698