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

Side by Side Diff: packages/utf/lib/src/list_range.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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 | « packages/utf/codereview.settings ('k') | packages/utf/lib/src/shared.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) 2012, 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 library utf.list_range; 5 library utf.list_range;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 /** 9 /**
10 * _ListRange in an internal type used to create a lightweight Interable on a 10 * _ListRange in an internal type used to create a lightweight Interable on a
11 * range within a source list. DO NOT MODIFY the underlying list while 11 * range within a source list. DO NOT MODIFY the underlying list while
12 * iterating over it. The results of doing so are undefined. 12 * iterating over it. The results of doing so are undefined.
13 */ 13 */
14 // TODO(floitsch): Consider removing the extend and switch to implements since 14 // TODO(floitsch): Consider removing the extend and switch to implements since
15 // that's cheaper to allocate. 15 // that's cheaper to allocate.
16 class ListRange extends IterableBase { 16 class ListRange extends IterableBase<int> {
17 final List _source; 17 final List<int> _source;
18 final int _offset; 18 final int _offset;
19 final int _length; 19 final int _length;
20 20
21 ListRange(source, [offset = 0, length]) : 21 ListRange(List<int> source, [offset = 0, length])
22 this._source = source, 22 : this._source = source,
23 this._offset = offset, 23 this._offset = offset,
24 this._length = (length == null ? source.length - offset : length) { 24 this._length = (length == null ? source.length - offset : length) {
25 if (_offset < 0 || _offset > _source.length) { 25 if (_offset < 0 || _offset > _source.length) {
26 throw new RangeError.value(_offset); 26 throw new RangeError.value(_offset);
27 } 27 }
28 if (_length != null && (_length < 0)) { 28 if (_length != null && (_length < 0)) {
29 throw new RangeError.value(_length); 29 throw new RangeError.value(_length);
30 } 30 }
31 if (_length + _offset > _source.length) { 31 if (_length + _offset > _source.length) {
32 throw new RangeError.value(_length + _offset); 32 throw new RangeError.value(_length + _offset);
33 } 33 }
34 } 34 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void backup([int by = 1]) { 70 void backup([int by = 1]) {
71 _offset -= by; 71 _offset -= by;
72 } 72 }
73 73
74 int get remaining => _end - _offset - 1; 74 int get remaining => _end - _offset - 1;
75 75
76 void skip([int count = 1]) { 76 void skip([int count = 1]) {
77 _offset += count; 77 _offset += count;
78 } 78 }
79 } 79 }
OLDNEW
« no previous file with comments | « packages/utf/codereview.settings ('k') | packages/utf/lib/src/shared.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698