--------------------------
 Find the is/should delta and add/remove commands as needed.

 Inputs:
 primary_and_range: An array of primary vlan and range of vlans
346243
def switchport_pvlan_mapping_delta(primary_and_range)
      # Enable switchport mode and feature private-vlan
      pvlan_enable
      primary, should_range = primary_and_range

      # primary changes require removing the entire command first
      is_range = switchport_pvlan_mapping_remove?(primary)

      # convert ranges to individual elements
      is = Utils.dash_range_to_elements(is_range)
      should = Utils.dash_range_to_elements(should_range)

      # create the delta hash and apply the changes
      delta_hash = Utils.delta_add_remove(should, is)
      Cisco::Logger.debug('switchport_pvlan_mapping_delta: '\
                          "#{primary}: #{delta_hash}")
      [:add, :remove].each do |action|
        delta_hash[action].each do |vlan|
          state = (action == :add) ? '' : 'no'
          cli_error_check(
            config_set('interface', 'switchport_pvlan_mapping',
                       name: @name, state: state, primary: primary, vlan: vlan))
        end
      end
    end
479916
def switchport_pvlan_trunk_association=(should)
      pvlan_enable

      # Handle single-level arrays if found: [pri, sec] -> [[pri,sec]]
      should = [should] if !should.empty? && (Utils.depth(should) == 1)

      is = switchport_pvlan_trunk_association
      pvlan_trunk_association_delta(is, should)
    end
152051
function range(start, stop, step) {
  if (start != null && typeof start != 'number') {
    throw new Error('start must be a number or null');
  }
  if (stop != null && typeof stop != 'number') {
    throw new Error('stop must be a number or null');
  }
  if (step != null && typeof step != 'number') {
    throw new Error('step must be a number or null');
  }
  if (stop == null) {
    stop = start || 0;
    start = 0;
  }
  if (step == null) {
    step = stop > start ? 1 : -1;
  }
  var toReturn = [];
  var increasing = start < stop; //← here’s the change
  for (; increasing ? start < stop : start > stop; start += step) {
    toReturn.push(start);
  }
  return toReturn;
}
277476
function rangeToLines(range) {
    range = (range || '').split(':');
    if (range.length != 2) {
        return null;
    }

    return {
        start: Number(range[0]) - 1,
        end: Number(range[1]) - 1
    }
}
880652
function analyzeRange (range, targetSha, conf) {
  return git.run("diff -u " + range).then(function (diff) {
    var filesPatterns = conf.files;
    if (!_.isArray(filesPatterns)) {
      filesPatterns = filesPatterns.split(",");
    }
    filesPatterns = _.invoke(filesPatterns, "trim");

    return analyzeDiff(_.filter(parseDiff(diff), function (file) {
      if (!file.to) {
        debug("Ignore deletion", file.from);
        return false;
      }

      var ignored = isIgnored(file.to, filesPatterns);
      if (ignored === null) {
        // Could not decide: hardcoded default = safe = ignore file
        ignored = true;
      }

      if (ignored) {
        debug("Ignore", file.to);
      }
      return !ignored;
    }), targetSha, conf);
  });
}
136726
def detect_range(line = None):
    '''
    
    '''
    if (not line.startswith("[") and
        line.find("[") != -1 and
        line.find(":") != -1 and
        line.find("]") != -1 and
        line.index("[") < line.index(":") < line.index("]")):
        return True
    else:
        return False
851290
def _numeric_param_check_range(variable_name, variable_value, range_bottom, range_top):
    
    err_msg = "%s must be between %i and %i"

    if variable_value < range_bottom or variable_value > range_top:
        raise ToolkitError(err_msg % (variable_name, range_bottom, range_top))
1136570
def _get_vlan_list(self, vlan_str):
        

        result = set()
        for splitted_vlan in vlan_str.split(","):
            if "-" not in splitted_vlan:
                if validate_vlan_number(splitted_vlan):
                    result.add(int(splitted_vlan))
                else:
                    raise Exception(self.__class__.__name__, "Wrong VLAN number detected {}".format(splitted_vlan))
            else:
                if self.IS_VLAN_RANGE_SUPPORTED:
                    if validate_vlan_range(splitted_vlan):
                        result.add(splitted_vlan)
                    else:
                        raise Exception(self.__class__.__name__, "Wrong VLANs range detected {}".format(vlan_str))
                else:
                    start, end = map(int, splitted_vlan.split("-"))
                    if validate_vlan_number(start) and validate_vlan_number(end):
                        if start > end:
                            start, end = end, start
                        for vlan in range(start, end + 1):
                            result.add(vlan)
                    else:
                        raise Exception(self.__class__.__name__, "Wrong VLANs range detected {}".format(vlan_str))

        return map(str, list(result))
447086
def parse_vmnet_range(start, end):
    

    class Range(argparse.Action):

        def __call__(self, parser, args, values, option_string=None):
            if len(values) != 2:
                raise argparse.ArgumentTypeError("vmnet range must consist of 2 numbers")
            if not start <= values[0] or not values[1] <= end:
                raise argparse.ArgumentTypeError("vmnet range must be between {} and {}".format(start, end))
            setattr(args, self.dest, values)
    return Range
855877
def networks=(should_list)
      delta_hash = Utils.delta_add_remove(should_list, networks)
      return if delta_hash.values.flatten.empty?
      [:add, :remove].each do |action|
        Cisco::Logger.debug("networks delta #{@get_args}\n #{action}: " \
                            "#{delta_hash[action]}")
        delta_hash[action].each do |network, route_map_policy|
          state = (action == :add) ? '' : 'no'
          network = Utils.process_network_mask(network)
          unless route_map_policy.nil?
            route_map = "route-map #{route_map_policy}"
            route_policy = "route-policy #{route_map_policy}"
          end
          set_args_keys(state: state, network: network, route_map: route_map,
                        route_policy: route_policy)
          config_set('bgp_af', 'networks', @set_args)
        end
      end
    end
774087
def _range(self, memory, addr, **kwargs):
        
        return (self._min(memory, addr, **kwargs), self._max(memory, addr, **kwargs))
551756
def pvlan_mapping
      range = config_get('interface', 'pvlan_mapping', name: @name)
      return default_pvlan_mapping if range.nil?
      range.empty? ? range : [range.delete(' ')]
    end
1008350
function(ranges) {
      let unstaggeredRanges = [];
      ranges.forEach(function(range) {
        let isStaggered = unstaggeredRanges.some(function(unstaggeredRange) {
          let isStartInside =
            range[0] > unstaggeredRange[0] && range[0] < unstaggeredRange[1];
          let isStopInside =
            range[1] > unstaggeredRange[0] && range[1] < unstaggeredRange[1];
          return isStartInside !== isStopInside; // xor
        });
        if (!isStaggered) {
          unstaggeredRanges.push(range);
        }
      });
      return unstaggeredRanges;
    }
578543
def search_range(nums, target):
    
    low = 0
    high = len(nums) - 1
    while low <= high:
        mid = low + (high - low) // 2
        if target < nums[mid]:
            high = mid - 1
        elif target > nums[mid]:
            low = mid + 1
        else:
            break

    for j in range(len(nums) - 1, -1, -1):
        if nums[j] == target:
            return [mid, j]

    return [-1, -1]
958545
function findSystemPortRange() {
  if (systemRange) {
    return systemRange;
  }
  var range = process.platform === 'win32' ?
      findWindowsPortRange() : findUnixPortRange();
  return systemRange = range.thenCatch(function() {
    return DEFAULT_IANA_RANGE;
  });
}
37319
function range(start, stop) {
  if (arguments.length <= 1) {
    stop = start || 0;
    start = 0;
  }

  var length = Math.max(stop - start, 0);
  var idx = 0;
  var arr = new Array(length);

  while(idx < length) {
    arr[idx++] = start;
    start += 1;
  }

  return arr;
}
113371
def _fusion_range_to_dsl(tokens) -> FusionRangeBase:
    
    if FUSION_MISSING in tokens:
        return missing_fusion_range()

    return fusion_range(
        reference=tokens[FUSION_REFERENCE],
        start=tokens[FUSION_START],
        stop=tokens[FUSION_STOP]
    )