Create a new collection consisting of every n-th element.

        :param step: The step size
        :type step: int

        :param offset: The start offset
        :type offset: int

        :rtype: Collection
183988
def every(self, step, offset=0):
        
        new = []

        for position, item in enumerate(self.items):
            if position % step == offset:
                new.append(item)

        return self.__class__(new)
560425
def step(self)->Number:
        ""
        self.n += 1
        return self.func(self.start, self.end, self.n/self.n_iter)
866569
public function skip(int $step): ArrayCollection
    {
        $items = [];
        $pos = 0;

        foreach ($this->items as $key => $value) {
            if ($pos % $step === 0) {
                $items[$key] = $value;
            }
            $pos++;
        }

        return new static($items);
    }
85139
public static int[] range(int start, int stop, int step) {
		if (start < stop) {
			step = Math.abs(step);
		} else if (start > stop) {
			step = -Math.abs(step);
		} else {// start == end
			return new int[] { start };
		}

		int size = Math.abs((stop - start) / step) + 1;
		int[] values = new int[size];
		int index = 0;
		for (int i = start; (step > 0) ? i <= stop : i >= stop; i += step) {
			values[index] = i;
			index++;
		}
		return values;
	}
1263618
def generate(self, step, params):
        
        subfactory = self.get_factory()
        logger.debug(
            "SubFactory: Instantiating %s.%s(%s), create=%r",
            subfactory.__module__, subfactory.__name__,
            utils.log_pprint(kwargs=params),
            step,
        )
        force_sequence = step.sequence if self.FORCE_SEQUENCE else None
        return step.recurse(subfactory, params, force_sequence=force_sequence)
653373
def add(self, interval, offset):
        
        start, stop = self.get_start_stop(interval)

        if len(self.starts) > 0:
            if start < self.starts[-1] or offset <= self.offsets[-1][1]:
                raise ValueError('intervals and offsets must be added in-order')
            self.offsets[-1][1] = offset
            self.offsets[-1][2] += 1
        else:
            self.starts.append(start)
            self.stops.append(stop)
            self.offsets.append([offset, offset, 1])
1261436
def async_steps(self, n):
        
        assert len(self._agents_to_act) == 0
        for _ in range(n):
            self.async_step()
689321
public static <T> List<T> sub(List<T> list, int start, int end, int step) {
		if (list == null || list.isEmpty()) {
			return null;
		}

		final int size = list.size();
		if (start < 0) {
			start += size;
		}
		if (end < 0) {
			end += size;
		}
		if (start == size) {
			return new ArrayList<>(0);
		}
		if (start > end) {
			int tmp = start;
			start = end;
			end = tmp;
		}
		if (end > size) {
			if (start >= size) {
				return new ArrayList<>(0);
			}
			end = size;
		}

		if (step <= 1) {
			return list.subList(start, end);
		}

		final List<T> result = new ArrayList<>();
		for (int i = start; i < end; i += step) {
			result.add(list.get(i));
		}
		return result;
	}
826239
public static Integer[] sequence(final Integer from, final Integer to, final Integer step) {
        
        Validate.notNull(from, "Value to start the sequence from cannot be null");
        Validate.notNull(to, "Value to generate the sequence up to cannot be null");
        Validate.notNull(step, "Step to generate the sequence cannot be null");
        
        final int iFrom = from.intValue();
        final int iTo = to.intValue();
        final int iStep = step.intValue();

        if (iFrom == iTo) {
            return new Integer[] {Integer.valueOf(iFrom)};
        }

        if (iStep == 0) {
            // with iStep == 0, this would only be valid if iFrom == iTo, which it isn't - the rest are impossible
            throw new IllegalArgumentException("Cannot create sequence from " + iFrom + " to " + iTo + " with step " + iStep);
        }

        final List<Integer> values = new ArrayList<Integer>(10);
        if (iFrom < iTo && iStep > 0) {
            int i = iFrom;
            while (i <= iTo) {
                values.add(Integer.valueOf(i));
                i += iStep;
            }
        } else if (iFrom > iTo && iStep < 0){
            // iFrom > iTo
            int i = iFrom;
            while (i >= iTo) {
                values.add(Integer.valueOf(i));
                i += iStep;
            }
        }

        return values.toArray(new Integer[values.size()]);
        
    }
402359
def offset_gen(offset, iterable, skip_signal=None):
  '''
  '''
  offset = int(offset)
  assert offset >= 0, 'negative offset'

  for item in iterable:
    if offset > 0:
      offset -= 1
      if callable(skip_signal):
        skip_signal(item)
    else:
      yield item
474127
def create(self, collection, **kw):
		
		
		options = dict(
				name = self.__name__,
				unique = self.unique,
				background = self.background,
				sparse = self.sparse,
				expireAfterSeconds = self.expire,
				partialFilterExpression = self.partial,
				bucketSize = self.bucket,
				min = self.min,
				max = self.max,
			)
		options.update(kw)
		
		# Clear null options.
		for key in list(options):
			if options[key] is None:
				del options[key]
		
		return collection.create_index(self.fields, **options)
1198187
def _expand_inputs(step, steps=None):
    
    if steps is None:
        steps = set()

    for arg in step._kwargs.values():
        if isinstance(arg, Step):
            _expand_inputs(arg, steps=steps)
        elif util.is_instance_collection(arg, Step):
            for s in util.get_collection_values(arg):
                _expand_inputs(s, steps=steps)

    steps.add(step)
    return steps
789546
def shuffle_step(entries, step):
    '''
    
    '''
    answer = []
    for i in range(0, len(entries), step):
        sub = entries[i:i+step]
        shuffle(sub)
        answer += sub
    return answer
141779
def add_step(self, setting, duration):
        
        if len(self._prog_steps) < 10:
            self._prog_steps.append(ProgramStep(self, setting, duration))
        else:
            raise IndexError("Maximum of 10 steps are allowed")
708309
def __step3(self):
        
        n = self.n
        count = 0
        for i in range(n):
            for j in range(n):
                if self.marked[i][j] == 1:
                    self.col_covered[j] = True
                    count += 1

        if count >= n:
            step = 7 # done
        else:
            step = 4

        return step
342335
public static <T> void addAll(Collection<T> col, Enumeration<T> e) {
		while (e.hasMoreElements())
			col.add(e.nextElement());
	}
788192
def new_collection(query, resources = nil, &block)
      if loaded?
        resources ||= filter(query)
      end

      # TOOD: figure out a way to pass not-yet-saved Resources to this newly
      # created Collection.  If the new resource matches the conditions, then
      # it should be added to the collection (keep in mind limit/offset too)

      self.class.new(query, resources, &block)
    end