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

Side by Side Diff: packages/collection/lib/src/combined_wrappers/combined_list.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
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:collection';
6
7 /// A view of several lists combined into a single list.
8 ///
9 /// All methods and accessors treat the [CombinedListView] list as if it were a
10 /// single concatenated list, but the underlying implementation is based on
11 /// lazily accessing individual list instances. This means that if the
12 /// underlying lists change, the [CombinedListView] will reflect those changes.
13 ///
14 /// The index operator (`[]`) and [length] property of a [CombinedListView] are
15 /// both `O(lists)` rather than `O(1)`. A [CombinedListView] is unmodifiable.
16 class CombinedListView<T> extends ListBase<T>
17 implements UnmodifiableListView<T> {
18 static void _throw() {
19 throw new UnsupportedError('Cannot modify an unmodifiable List');
20 }
21
22 /// The lists that this combines.
23 final List<List<T>> _lists;
24
25 /// Creates a combined view of [lists].
26 CombinedListView(this._lists);
27
28 set length(int length) {
29 _throw();
30 }
31
32 int get length => _lists.fold(0, (length, list) => length + list.length);
33
34 T operator [](int index) {
35 var initialIndex = index;
36 for (var i = 0; i < _lists.length; i++) {
37 var list = _lists[i];
38 if (index < list.length) {
39 return list[index];
40 }
41 index -= list.length;
42 }
43 throw new RangeError.index(initialIndex, this, 'index', null, length);
44 }
45
46 void operator []=(int index, T value) {
47 _throw();
48 }
49
50 void clear() {
51 _throw();
52 }
53
54 bool remove(Object element) {
55 _throw();
56 return null;
57 }
58
59 void removeWhere(bool filter(T element)) {
60 _throw();
61 }
62
63 void retainWhere(bool filter(T element)) {
64 _throw();
65 }
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698