allowsAny method

  1. @override
bool allowsAny(
  1. VersionConstraint other
)
override

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

Implementation

@override
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.
  var ourRangesMoved = ourRanges.moveNext();
  var theirRangesMoved = theirRanges.moveNext();
  while (ourRangesMoved && theirRangesMoved) {
    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)) {
      ourRangesMoved = ourRanges.moveNext();
    } else {
      theirRangesMoved = theirRanges.moveNext();
    }
  }

  return false;
}