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

Unified Diff: packages/collection/lib/src/unmodifiable_wrappers.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 | « packages/collection/lib/src/union_set_controller.dart ('k') | packages/collection/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/collection/lib/src/unmodifiable_wrappers.dart
diff --git a/packages/collection/lib/src/unmodifiable_wrappers.dart b/packages/collection/lib/src/unmodifiable_wrappers.dart
index efe3c9d07edc05ff01ec570c1e9550424b2f592d..1b4d2e4bdd29e0cdb3c634931cfeced8a39030cc 100644
--- a/packages/collection/lib/src/unmodifiable_wrappers.dart
+++ b/packages/collection/lib/src/unmodifiable_wrappers.dart
@@ -2,236 +2,170 @@
// 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.
-/**
- * Wrappers that prevent a List, Set, or Map object from being modified.
- *
- * The [Set] and [Map] wrappers allow reading from the wrapped collection,
- * but prohibit writing.
- *
- * The [List] wrapper prevents changes to the length of the wrapped list,
- * but allows changes to the contents.
- */
-library collection.unmodifiable_wrappers;
-
-import '../wrappers.dart';
-
export "dart:collection" show UnmodifiableListView, UnmodifiableMapView;
-/**
- * A fixed-length list.
- *
- * A `NonGrowableListView` contains a [List] object and ensures that
- * its length does not change.
- * Methods that would change the length of the list,
- * such as [add] and [remove], throw an [UnsupportedError].
- * All other methods work directly on the underlying list.
- *
- * This class _does_ allow changes to the contents of the wrapped list.
- * You can, for example, [sort] the list.
- * Permitted operations defer to the wrapped list.
- */
+import 'wrappers.dart';
+import 'empty_unmodifiable_set.dart';
+
+/// A fixed-length list.
+///
+/// A `NonGrowableListView` contains a [List] object and ensures that
+/// its length does not change.
+/// Methods that would change the length of the list,
+/// such as [add] and [remove], throw an [UnsupportedError].
+/// All other methods work directly on the underlying list.
+///
+/// This class _does_ allow changes to the contents of the wrapped list.
+/// You can, for example, [sort] the list.
+/// Permitted operations defer to the wrapped list.
class NonGrowableListView<E> extends DelegatingList<E>
- with NonGrowableListMixin<E> {
+ with NonGrowableListMixin<E> {
NonGrowableListView(List<E> listBase) : super(listBase);
}
-/**
- * Mixin class that implements a throwing version of all list operations that
- * change the List's length.
- */
+/// Mixin class that implements a throwing version of all list operations that
+/// change the List's length.
abstract class NonGrowableListMixin<E> implements List<E> {
- static _throw() {
+ static T _throw<T>() {
throw new UnsupportedError(
"Cannot change the length of a fixed-length list");
}
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void set length(int newLength) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
bool add(E value) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void addAll(Iterable<E> iterable) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void insert(int index, E element) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void insertAll(int index, Iterable<E> iterable) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
bool remove(Object value) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
E removeAt(int index) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
E removeLast() => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void removeWhere(bool test(E element)) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void retainWhere(bool test(E element)) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void removeRange(int start, int end) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void replaceRange(int start, int end, Iterable<E> iterable) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the length of the list are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the length of the list are disallowed.
void clear() => _throw();
}
-/**
- * An unmodifiable set.
- *
- * An UnmodifiableSetView contains a [Set] object and ensures
- * that it does not change.
- * Methods that would change the set,
- * such as [add] and [remove], throw an [UnsupportedError].
- * Permitted operations defer to the wrapped set.
- */
+/// An unmodifiable set.
+///
+/// An UnmodifiableSetView contains a [Set] object and ensures
+/// that it does not change.
+/// Methods that would change the set,
+/// such as [add] and [remove], throw an [UnsupportedError].
+/// Permitted operations defer to the wrapped set.
class UnmodifiableSetView<E> extends DelegatingSet<E>
- with UnmodifiableSetMixin<E> {
+ with UnmodifiableSetMixin<E> {
UnmodifiableSetView(Set<E> setBase) : super(setBase);
+
+ /// An unmodifiable empty set.
+ ///
+ /// This is the same as `new UnmodifiableSetView(new Set())`, except that it
+ /// can be used in const contexts.
+ const factory UnmodifiableSetView.empty() = EmptyUnmodifiableSet<E>;
}
-/**
- * Mixin class that implements a throwing version of all set operations that
- * change the Set.
- */
+/// Mixin class that implements a throwing version of all set operations that
+/// change the Set.
abstract class UnmodifiableSetMixin<E> implements Set<E> {
- _throw() {
+ static T _throw<T>() {
throw new UnsupportedError("Cannot modify an unmodifiable Set");
}
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
bool add(E value) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
void addAll(Iterable<E> elements) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
bool remove(Object value) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
void removeAll(Iterable elements) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
void retainAll(Iterable elements) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
void removeWhere(bool test(E element)) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
void retainWhere(bool test(E element)) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the set are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the set are disallowed.
void clear() => _throw();
}
-/**
- * Mixin class that implements a throwing version of all map operations that
- * change the Map.
- */
+/// Mixin class that implements a throwing version of all map operations that
+/// change the Map.
abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> {
- static _throw() {
+ static T _throw<T>() {
throw new UnsupportedError("Cannot modify an unmodifiable Map");
}
- /**
- * Throws an [UnsupportedError];
- * operations that change the map are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the map are disallowed.
void operator []=(K key, V value) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the map are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the map are disallowed.
V putIfAbsent(K key, V ifAbsent()) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the map are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the map are disallowed.
void addAll(Map<K, V> other) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the map are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the map are disallowed.
V remove(Object key) => _throw();
- /**
- * Throws an [UnsupportedError];
- * operations that change the map are disallowed.
- */
+ /// Throws an [UnsupportedError];
+ /// operations that change the map are disallowed.
void clear() => _throw();
}
« no previous file with comments | « packages/collection/lib/src/union_set_controller.dart ('k') | packages/collection/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698