-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
collections.dart
26 lines (20 loc) · 952 Bytes
/
collections.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.6
part of dart.collection;
/// An unmodifiable [List] view of another List.
///
/// The source of the elements may be a [List] or any [Iterable] with
/// efficient [Iterable.length] and [Iterable.elementAt].
class UnmodifiableListView<E> extends UnmodifiableListBase<E> {
final Iterable<E> _source;
/// Creates an unmodifiable list backed by [source].
///
/// The [source] of the elements may be a [List] or any [Iterable] with
/// efficient [Iterable.length] and [Iterable.elementAt].
UnmodifiableListView(Iterable<E> source) : _source = source;
List<R> cast<R>() => UnmodifiableListView(_source.cast<R>());
int get length => _source.length;
E operator [](int index) => _source.elementAt(index);
}