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

Unified Diff: pkg/observe/lib/src/observable_list.dart

Issue 178683003: [observe] use consistent comment style (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « pkg/observe/lib/src/observable_box.dart ('k') | pkg/observe/lib/src/observable_map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/src/observable_list.dart
diff --git a/pkg/observe/lib/src/observable_list.dart b/pkg/observe/lib/src/observable_list.dart
index f7052ff22234fb09a804fee8f8f1495f3e997865..4a6b56a6ef3513369ea74b540df4ddb54fbe4109 100644
--- a/pkg/observe/lib/src/observable_list.dart
+++ b/pkg/observe/lib/src/observable_list.dart
@@ -9,60 +9,52 @@ import 'dart:collection' show ListBase, UnmodifiableListView;
import 'package:observe/observe.dart';
import 'list_diff.dart' show projectListSplices, calcSplices;
-/**
- * Represents an observable list of model values. If any items are added,
- * removed, or replaced, then observers that are listening to [changes]
- * will be notified.
- */
+/// Represents an observable list of model values. If any items are added,
+/// removed, or replaced, then observers that are listening to [changes]
+/// will be notified.
class ObservableList<E> extends ListBase<E> with ChangeNotifier {
List<ListChangeRecord> _listRecords;
StreamController _listChanges;
- /** The inner [List<E>] with the actual storage. */
+ /// The inner [List<E>] with the actual storage.
final List<E> _list;
- /**
- * Creates an observable list of the given [length].
- *
- * If no [length] argument is supplied an extendable list of
- * length 0 is created.
- *
- * If a [length] argument is supplied, a fixed size list of that
- * length is created.
- */
+ /// Creates an observable list of the given [length].
+ ///
+ /// If no [length] argument is supplied an extendable list of
+ /// length 0 is created.
+ ///
+ /// If a [length] argument is supplied, a fixed size list of that
+ /// length is created.
ObservableList([int length])
: _list = length != null ? new List<E>(length) : <E>[];
- /**
- * Creates an observable list with the elements of [other]. The order in
- * the list will be the order provided by the iterator of [other].
- */
+ /// Creates an observable list with the elements of [other]. The order in
+ /// the list will be the order provided by the iterator of [other].
factory ObservableList.from(Iterable<E> other) =>
new ObservableList<E>()..addAll(other);
- /**
- * The stream of summarized list changes, delivered asynchronously.
- *
- * Each list change record contains information about an individual mutation.
- * The records are projected so they can be applied sequentially. For example,
- * this set of mutations:
- *
- * var model = new ObservableList.from(['a', 'b']);
- * model.listChanges.listen((records) => records.forEach(print));
- * model.removeAt(1);
- * model.insertAll(0, ['c', 'd', 'e']);
- * model.removeRange(1, 3);
- * model.insert(1, 'f');
- *
- * The change records will be summarized so they can be "played back", using
- * the final list positions to figure out which item was added:
- *
- * #<ListChangeRecord index: 0, removed: [], addedCount: 2>
- * #<ListChangeRecord index: 3, removed: [b], addedCount: 0>
- *
- * [deliverChanges] can be called to force synchronous delivery.
- */
+ /// The stream of summarized list changes, delivered asynchronously.
+ ///
+ /// Each list change record contains information about an individual mutation.
+ /// The records are projected so they can be applied sequentially. For
+ /// example, this set of mutations:
+ ///
+ /// var model = new ObservableList.from(['a', 'b']);
+ /// model.listChanges.listen((records) => records.forEach(print));
+ /// model.removeAt(1);
+ /// model.insertAll(0, ['c', 'd', 'e']);
+ /// model.removeRange(1, 3);
+ /// model.insert(1, 'f');
+ ///
+ /// The change records will be summarized so they can be "played back", using
+ /// the final list positions to figure out which item was added:
+ ///
+ /// #<ListChangeRecord index: 0, removed: [], addedCount: 2>
+ /// #<ListChangeRecord index: 3, removed: [b], addedCount: 0>
+ ///
+ /// [deliverChanges] can be called to force synchronous delivery.
Stream<List<ListChangeRecord>> get listChanges {
if (_listChanges == null) {
// TODO(jmesserly): split observed/unobserved notions?
@@ -272,28 +264,24 @@ class ObservableList<E> extends ListBase<E> with ChangeNotifier {
return false;
}
- /**
- * Calculates the changes to the list, if lacking individual splice mutation
- * information.
- *
- * This is not needed for change records produced by [ObservableList] itself,
- * but it can be used if the list instance was replaced by another list.
- *
- * The minimal set of splices can be synthesized given the previous state and
- * final state of a list. The basic approach is to calculate the edit distance
- * matrix and choose the shortest path through it.
- *
- * Complexity is `O(l * p)` where `l` is the length of the current list and
- * `p` is the length of the old list.
- */
+ /// Calculates the changes to the list, if lacking individual splice mutation
+ /// information.
+ ///
+ /// This is not needed for change records produced by [ObservableList] itself,
+ /// but it can be used if the list instance was replaced by another list.
+ ///
+ /// The minimal set of splices can be synthesized given the previous state and
+ /// final state of a list. The basic approach is to calculate the edit
+ /// distance matrix and choose the shortest path through it.
+ ///
+ /// Complexity is `O(l * p)` where `l` is the length of the current list and
+ /// `p` is the length of the old list.
static List<ListChangeRecord> calculateChangeRecords(
List<Object> oldValue, List<Object> newValue) =>
calcSplices(newValue, 0, newValue.length, oldValue, 0, oldValue.length);
- /**
- * Updates the [previous] list using the change [records]. For added items,
- * the [current] list is used to find the current value.
- */
+ /// Updates the [previous] list using the change [records]. For added items,
+ /// the [current] list is used to find the current value.
static void applyChangeRecords(List<Object> previous, List<Object> current,
List<ListChangeRecord> changeRecords) {
« no previous file with comments | « pkg/observe/lib/src/observable_box.dart ('k') | pkg/observe/lib/src/observable_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698