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

Unified Diff: sdk/lib/collection/collections.dart

Issue 12259045: Add unmodifiable list view. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/collections.dart
diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart
index 18c1d7b73c02e56818d2f213cffe382095815990..06aa7677c73b96bd51a0f7e5d5a770ccd6e690a2 100644
--- a/sdk/lib/collection/collections.dart
+++ b/sdk/lib/collection/collections.dart
@@ -500,3 +500,17 @@ class Collections {
static String collectionToString(Collection c)
=> ToString.collectionToString(c);
}
+
+/**
+ * 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> {
+ Iterable<E> _source;
+ /** Create an unmodifiable list backed by [source]. */
+ UnmodifiableListView(Iterable<E> source) : _source = source;
+ int get length => _source.length;
+ E operator[](int index) => _source.elementAt(index);
+}
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698