target property

Iterable<T> get target

Returns the target iterable.

Implementation

Iterable<T> get target => _target;
set target (Iterable<T> iterable)

Sets the target iterable to be compared.

Implementation

set target(Iterable<T> iterable) {
  _matches.clear();
  _operations.clear();
  _target.clear();
  _target.addAll(iterable);
  // Compute the target indices.
  _targetIndices.clear();
  for (var i = 0; i < _target.length; i++) {
    _targetIndices[_target[i]].add(i);
  }
  // Compute junk elements.
  _targetJunk.clear();
  if (_isJunk != null) {
    for (final element in _targetIndices.keys) {
      if (_isJunk(element)) {
        _targetJunk.add(element);
      }
    }
    for (final element in _targetJunk) {
      _targetIndices.removeAll(element);
    }
  }
  // Compute popular elements, that are not junk.
  _targetPopular.clear();
  if (_autoJunk && _target.length >= 200) {
    final cutoff = _target.length ~/ 100 + 1;
    for (final entry in _targetIndices.asMap().entries) {
      if (entry.values.length > cutoff) {
        _targetPopular.add(entry.key);
      }
    }
    for (final element in _targetPopular) {
      _targetIndices.removeAll(element);
    }
  }
}