prune method

void prune(
  1. Set<String> inUse
)

Deletes the oldest segments not in inUse until at most maxSegments remain.

Implementation

void prune(Set<String> inUse) {
  final excess = _files.length - maxSegments;
  if (excess <= 0) return;
  final victims = _files.keys.where((k) => !inUse.contains(k)).take(excess).toList();
  for (final key in victims) {
    _delete(_files.remove(key));
  }
}