collapseAllInRegistry method

void collapseAllInRegistry(
  1. int? maxDepth,
  2. List<TKey> roots
)

Clears the expanded flag for every registered node whose depth is less than maxDepth (or for every node when maxDepth is null), then rebuilds the ancestors-expanded cache from roots.

Implementation

void collapseAllInRegistry(int? maxDepth, List<TKey> roots) {
  if (maxDepth == null) {
    _expandedByNid.fillRange(0, _expandedByNid.length, 0);
  } else {
    final n = nids.length;
    for (int nid = 0; nid < n; nid++) {
      if (nids.isFree(nid)) continue;
      if (_expandedByNid[nid] == 0) continue;
      if (_depthByNid[nid] < maxDepth) {
        _expandedByNid[nid] = 0;
      }
    }
  }
  rebuildAllAncestorsExpanded(roots);
}