allowsAny method

bool allowsAny (VersionConstraint other)
override

Returns true if this constraint allows any of the versions that other allows.

Implementation

bool allowsAny(VersionConstraint other) {
  var ourRanges = ranges.iterator;
  var theirRanges = _rangesFor(other).iterator;

  // Because both lists of ranges are ordered by minimum version, we can
  // safely move through them linearly here.
  ourRanges.moveNext();
  theirRanges.moveNext();
  while (ourRanges.current != null && theirRanges.current != null) {
    if (ourRanges.current.allowsAny(theirRanges.current)) {
      return true;
    }

    // Move the constraint with the lower max value forward. This ensures that
    // we keep both lists in sync as much as possible.
    if (allowsHigher(theirRanges.current, ourRanges.current)) {
      ourRanges.moveNext();
    } else {
      theirRanges.moveNext();
    }
  }

  return false;
}