LCOV - code coverage report
Current view: top level - collection-1.14.3/lib/src/combined_wrappers - combined_list.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 0 15 0.0 %
Date: 2017-10-10 20:17:03 Functions: 0 0 -

          Line data    Source code
       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           0 :     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           0 :   CombinedListView(this._lists);
      27             : 
      28             :   set length(int length) {
      29           0 :     _throw();
      30             :   }
      31             : 
      32           0 :   int get length => _lists.fold(0, (length, list) => length + list.length);
      33             : 
      34             :   T operator [](int index) {
      35             :     var initialIndex = index;
      36           0 :     for (var i = 0; i < _lists.length; i++) {
      37           0 :       var list = _lists[i];
      38           0 :       if (index < list.length) {
      39           0 :         return list[index];
      40             :       }
      41           0 :       index -= list.length;
      42             :     }
      43           0 :     throw new RangeError.index(initialIndex, this, 'index', null, length);
      44             :   }
      45             : 
      46             :   void operator []=(int index, T value) {
      47           0 :     _throw();
      48             :   }
      49             : 
      50             :   void clear() {
      51           0 :     _throw();
      52             :   }
      53             : 
      54             :   bool remove(Object element) {
      55           0 :     _throw();
      56             :     return null;
      57             :   }
      58             : 
      59             :   void removeWhere(bool filter(T element)) {
      60           0 :     _throw();
      61             :   }
      62             : 
      63             :   void retainWhere(bool filter(T element)) {
      64           0 :     _throw();
      65             :   }
      66             : }

Generated by: LCOV version 1.13