Skip to content

Commit e11de59

Browse files
committed
doc(dccd): Improve the API doc
1 parent e131da1 commit e11de59

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

lib/change_detection/dirty_checking_change_detector.dart

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,8 @@ class _CollectionChangeRecord<V> implements CollectionChangeRecord<V> {
983983
}
984984

985985
/**
986-
* Reset the state of the change objects to show no changes. This means set
987-
* previousKey to currentKey, and clear all of the queues (additions, moves,
988-
* removals).
986+
* Reset the state of the change objects to show no changes. This means set previousKey to
987+
* currentKey, and clear all of the queues (additions, moves, removals).
989988
*/
990989
void _reset() {
991990
if (isDirty) {
@@ -999,6 +998,8 @@ class _CollectionChangeRecord<V> implements CollectionChangeRecord<V> {
999998
}
1000999
}
10011000

1001+
/// Set the [previousIndex]es of moved and added items to their [currentIndex]es
1002+
/// Reset the list of additions, moves and removals
10021003
void _undoDeltas() {
10031004
ItemRecord<V> record;
10041005

@@ -1021,19 +1022,16 @@ class _CollectionChangeRecord<V> implements CollectionChangeRecord<V> {
10211022
assert(isDirty == false);
10221023
}
10231024

1024-
/**
1025-
* A [_CollectionChangeRecord] is considered dirty if it has additions, moves
1026-
* or removals.
1027-
*/
1025+
/// A [_CollectionChangeRecord] is considered dirty if it has additions, moves or removals.
10281026
bool get isDirty => _additionsHead != null ||
10291027
_movesHead != null ||
10301028
_removalsHead != null;
10311029

10321030
/**
10331031
* This is the core function which handles differences between collections.
10341032
*
1035-
* - [record] is the record which we saw at this position last time. If
1036-
* [:null:] then it is a new item.
1033+
* - [record] is the record which we saw at this position last time. If [:null:] then it is a new
1034+
* item.
10371035
* - [item] is the current item in the collection
10381036
* - [index] is the position of the item in the collection
10391037
*/
@@ -1325,15 +1323,15 @@ class ItemRecord<V> extends CollectionChangeItem<V> {
13251323
: '$item[$previousIndex -> $currentIndex]';
13261324
}
13271325

1326+
/// A linked list of [ItemRecord]s with the same [ItemRecord.item]
13281327
class _DuplicateItemRecordList {
13291328
ItemRecord head, tail;
13301329

13311330
/**
1332-
* Add the [record] before the [previousRecord] in the list of duplicates or
1333-
* at the end of the list when no [previousRecord] is specified.
1331+
* Add the [record] before the [insertBefore] in the list of duplicates or at the end of the list
1332+
* when no [insertBefore] is specified.
13341333
*
1335-
* Note: by design all records in the list of duplicates hold the save value
1336-
* in [record.item].
1334+
* Note: by design all records in the list of duplicates hold the save value in [record.item].
13371335
*/
13381336
void add(ItemRecord record, ItemRecord previousRecord) {
13391337
assert(previousRecord == null || previousRecord.item == record.item);
@@ -1364,7 +1362,9 @@ class _DuplicateItemRecordList {
13641362
}
13651363
}
13661364

1367-
ItemRecord get(key, int hideIndex) {
1365+
/// Returns an [ItemRecord] having [ItemRecord.item] == [item] and [ItemRecord.currentIndex] >=
1366+
/// [hideIndex]
1367+
ItemRecord get(item, int hideIndex) {
13681368
ItemRecord record;
13691369
for (record = head; record != null; record = record._nextDup) {
13701370
if ((hideIndex == null || hideIndex < record.currentIndex) &&
@@ -1378,7 +1378,7 @@ class _DuplicateItemRecordList {
13781378
/**
13791379
* Remove one [ItemRecord] from the list of duplicates.
13801380
*
1381-
* Returns whether when the list of duplicates is empty.
1381+
* Returns whether the list of duplicates is empty.
13821382
*/
13831383
bool remove(ItemRecord record) {
13841384
assert(() {
@@ -1406,11 +1406,10 @@ class _DuplicateItemRecordList {
14061406
}
14071407

14081408
/**
1409-
* [DuplicateMap] maps [ItemRecord.value] to a list of [ItemRecord] having the
1410-
* same value (duplicates).
1409+
* [DuplicateMap] maps [ItemRecord.value] to a list of [ItemRecord] having the same value
1410+
* (duplicates).
14111411
*
14121412
* The list of duplicates is implemented by [_DuplicateItemRecordList].
1413-
*
14141413
*/
14151414
class DuplicateMap {
14161415
final map = <dynamic, _DuplicateItemRecordList>{};
@@ -1421,13 +1420,11 @@ class DuplicateMap {
14211420
}
14221421

14231422
/**
1424-
* Retrieve the `value` using [key]. Because the [ItemRecord] value maybe one
1425-
* which we have already iterated over, we use the [hideIndex] to pretend it
1426-
* is not there.
1423+
* Retrieve the `value` using [key]. Because the [ItemRecord] value maybe one which we have
1424+
* already iterated over, we use the [hideIndex] to pretend it is not there.
14271425
*
1428-
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a`
1429-
* then asking if we have any more `a`s needs to return the last `a` not the
1430-
* first or second.
1426+
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
1427+
* have any more `a`s needs to return the last `a` not the first or second.
14311428
*/
14321429
ItemRecord get(key, [int hideIndex]) {
14331430
_DuplicateItemRecordList recordList = map[key];

0 commit comments

Comments
 (0)