Iterate over keys within the passed range, splitting at an [a,b) boundary.
767122
public static Iterable<byte[]> iterateOnSplits(final byte[] a, final byte[] b, final int num) {
    return iterateOnSplits(a, b, false, num);
  }
305839
def keys(options = { })
      if options.include? :range
        warn "range supersedes prefix" if options[:prefix]
        range = options[:range]
        unless range.respond_to?(:first) and range.respond_to?(:last)
          fail ArgumentError, "Range or two element Array expected"
        end
        start          = cast_key_in(range.first)
        include_start  = !options.fetch(:exclude_start, false)
        finish         = cast_key_in(range.last)
        include_finish = !( range.respond_to?(:exclude_end?) ?
                            range.exclude_end?               :
                            options.fetch(:exclude_end, false) )
      else
        fail ArgumentError, "prefix not supported" if options[:prefix]
        start          = cast_key_in(:min)
        include_start  = true
        finish         = cast_key_in(:max)
        include_finish = true
      end
      limit = options.fetch(:limit, -1)
      Utilities.temp_int do |count|
        begin
          list  = lib.range(@db, start, finish, limit, count)
          array = list.get_array_of_uint64(0, count.get_int(0))
          array.shift if array.first == start  and not include_start
          array.pop   if array.last  == finish and not include_finish
          array  # cast not needed:  already Integer
        ensure
          Utilities.free(list) if list
        end
      end
    end
1341764
def split_input(val, mapper=None):
    '''
    
    '''
    if mapper is None:
        mapper = lambda x: x
    if isinstance(val, list):
        return list(map(mapper, val))
    try:
        return list(map(mapper, [x.strip() for x in val.split(',')]))
    except AttributeError:
        return list(map(mapper, [x.strip() for x in six.text_type(val).split(',')]))
952669
def expand_slice(s, a, b, start=0, stop=None):
    ''''''
    n1 = max(s.start - a, start)
    n2 = s.stop + b
    if stop is not None:
        n2 = min(n2, stop)

    return slice(n1, n2, 1)
422713
def ranges(self, start=None, stop=None):
		
		_check_start_stop(start, stop)
		start_loc = self._bisect_right(start)
		if stop is None:
			stop_loc = len(self._keys)
		else:
			stop_loc = self._bisect_left(stop)
		start_val = self._values[start_loc - 1]
		candidate_keys = [start] + self._keys[start_loc:stop_loc] + [stop]
		candidate_values = [start_val] + self._values[start_loc:stop_loc]
		for i, value in enumerate(candidate_values):
			if value is not NOT_SET:
				start_key = candidate_keys[i]
				stop_key = candidate_keys[i + 1]
				yield MappedRange(start_key, stop_key, value)
547068
def split_by_idxs(seq, idxs):
    ''' '''
    last = 0
    for idx in idxs:
        if not (-len(seq) <= idx < len(seq)):
          raise KeyError(f'Idx {idx} is out-of-bounds')
        yield seq[last:idx]
        last = idx
    yield seq[last:]
768930
def _normalize_slice(self, key, clamp=False):
        """"""
        if key.start is None:
            start = 0
        else:
            start = (len(self) + key.start) if key.start < 0 else key.start
        if key.stop is None or key.stop == maxsize:
            stop = len(self) if clamp else None
        else:
            stop = (len(self) + key.stop) if key.stop < 0 else key.stop
        return slice(start, stop, key.step or 1)
867455
def intranges_contain(int_, ranges):
    """"""
    tuple_ = _encode_range(int_, 0)
    pos = bisect.bisect_left(ranges, tuple_)
    # we could be immediately ahead of a tuple (start, end)
    # with start < int_ <= end
    if pos > 0:
        left, right = _decode_range(ranges[pos-1])
        if left <= int_ < right:
            return True
    # or we could be immediately behind a tuple (int_, end)
    if pos < len(ranges):
        left, _ = _decode_range(ranges[pos])
        if left == int_:
            return True
    return False
1235722
def _iter_key_ranges(self):
    """"""
    while True:
      if self._current_key_range is None:
        if self._key_ranges:
          self._current_key_range = self._key_ranges.pop()
          # The most recently popped key_range may be None, so continue here
          # to find the next keyrange that's valid.
          continue
        else:
          break

      for key, o in self._iter_key_range(
          copy.deepcopy(self._current_key_range)):
        # The caller must consume yielded values so advancing the KeyRange
        # before yielding is safe.
        self._current_key_range.advance(key)
        yield o
      self._current_key_range = None
193281
def split(orig, sep=None):
    '''
    
    '''
    exp = re.compile(r'\s+' if sep is None else re.escape(sep))
    pos = 0
    length = len(orig)
    while True:
        match = exp.search(orig, pos)
        if not match:
            if pos < length or sep is not None:
                val = orig[pos:]
                if val:
                    # Only yield a value if the slice was not an empty string,
                    # because if it is then we've reached the end. This keeps
                    # us from yielding an extra blank value at the end.
                    yield val
            break
        if pos < match.start() or sep is not None:
            yield orig[pos:match.start()]
        pos = match.end()
907309
function splitByRangeAndEnum(maybeUniverse, rangeToBeSplit) {
	var enumSet;

	// If it's an AND
	if (rangeToBeSplit instanceof is.And) {
		// recursively split each value
		var sets = rangeToBeSplit.values.map(function(setInAnd) {
			return splitByRangeAndEnum(maybeUniverse, setInAnd);
		});
		// take the intersections
		return sets.reduce(function(last, maybe) {
			return {
				range: set.intersection(last.range, maybe.range),
				enum: set.intersection(last.enum, maybe.enum)
			};
		}, {
			range: set.UNIVERSAL,
			enum: maybeUniverse
		});

	} else if (rangeToBeSplit instanceof is.In) {

		var shouldBeInValues = rangeToBeSplit.values.filter(function(value) {
			return maybeUniverse.isMember(value);
		});
		if (shouldBeInValues.length) {
			var valuesCopy = rangeToBeSplit.values.slice(0);
			canReflect.removeValues(valuesCopy, shouldBeInValues);

			return {
				enum: new is.In(shouldBeInValues),
				range: valuesCopy.length ? new is.In(valuesCopy) : set.EMPTY
			};
		} else {
			return {
				enum: set.EMPTY,
				range: rangeToBeSplit
			};
		}
	} else if (rangeToBeSplit instanceof is.NotIn) {

		// Gets the 'maybe' values in the range
		enumSet = set.intersection(maybeUniverse, rangeToBeSplit);

		// We should remove all the values within $in matching an in values.
		var rangeValues = rangeToBeSplit.values.filter(function(value) {
			return !maybeUniverse.isMember(value);
		});
		return {
			range: rangeValues.length ? new is.NotIn(rangeValues) : set.UNIVERSAL,
			enum: enumSet
		};
	} else {
		return {
			enum: set.EMPTY,
			range: rangeToBeSplit
		};
	}
}
241517
def split_every(n, iterable):
    """"""
    items = iter(iterable)
    return itertools.takewhile(bool, (list(itertools.islice(items, n)) for _ in itertools.count()))
1160829
def slice_on_length(self, data_len, *addSlices):
        '''
        
        '''
        if len(self.ordered_ranges) + len(addSlices) == 0:
            return slice(None,None,None)
        ranges = self.ordered_ranges
        if len(addSlices) > 0:
            ranges = ranges + DimensionRange(*addSlices).ordered_ranges
        return self._combine_lists_of_ranges_on_length(data_len, *ranges)
415187
function zrange(start, end, withscores) {
  var i
    , len = this._keys.length
    , list = [];
  if(start < 0) start = len + start;
  if(end < 0) end = len + end;
  if(start < 0) start = 0;
  if(end >= len) end = len - 1;
  i = start;
  for(;i <= end;i++) {
    list.push(this._keys[i].m);
    if(withscores) list.push(this._keys[i].v);
  }
  return list;
}
13066
def split_list_by(lst, key):
  

  first, second = [], []
  for item in lst:
    if key(item):
      second.append(item)
    else:
      first.append(item)
  return (first, second)
101158
def get_ranges(self, element, key):
        
        keys = self.p['keys']
        ranges = self.p['ranges']

        if ranges == {}:
            return {d.name: element.range(d.name, self.data_range)
                    for d in element.dimensions()}
        if keys is None:
            specs = ranges
        elif keys and not isinstance(ranges, list):
            raise ValueError("Key list specified but ranges parameter"
                             " not specified as a list.")
        elif len(keys) == len(ranges):
            # Unpack any 1-tuple keys
            try:
                index = keys.index(key)
                specs = ranges[index]
            except:
                raise KeyError("Could not match element key to defined keys")
        else:
            raise ValueError("Key list length must match length of supplied ranges")

        return match_spec(element, specs)
448525
def key_parts(key, &block)
      return enum_for(:key_parts, key) unless block
      nesting = PARENS
      counts  = PARENS_ZEROS # dup'd later if key contains parenthesis
      delim   = '.'
      from    = to = 0
      key.each_char do |char|
        if char == delim && PARENS_ZEROS == counts
          block.yield key[from...to]
          from = to = (to + 1)
        else
          nest_i, nest_inc = nesting[char]
          if nest_i
            counts = counts.dup if counts.frozen?
            counts[nest_i] += nest_inc
          end
          to += 1
        end
      end
      block.yield(key[from...to]) if from < to && to <= key.length
      true
    end