rewinds the collection to the first item when iterating with foreach
509871
public function rewind()
    {
        $this->_index = 0;
        $this->_currentPage = 0;
        $this->_pageSize = 0;
        $this->_totalItems = 0;
        $this->_items = [];
    }
750982
function(items, iterator, done) {
    done = done || function() {};
    var results = [];
    var failure = false;
    var expected = items.length;
    var current = -1;

    function callback(err, result) {
      if (err) return done(err);

      results.push(result);

      if (current == expected) {
        return done(null, results);
      } else {
        next();
      }
    }

    function next() {
      current += 1;

      var item = items[current];
      iterator(item, callback);
    }

    next()
  }
65995
function each (array, iterator, cb) {
  var len = array.length
  array.forEach(function (item, i) {
    iterator.call(null, item, i, done)
  })
  function done () {
    if (!--len) {
      return cb && cb()
    }
  }
}
718070
public static <T> T getFirst(Collection<T> collection) {
		if (isEmpty(collection)) {
			return null;
		}
		if (collection instanceof List) {
			return ((List<T>) collection).get(0);
		}
		return collection.iterator().next();
	}
215300
def refresh_items(self):
        
        old_items = self.items[:]# if self._dirty else []
        old_iter_data = self._iter_data# if self._dirty else {}
        iterable = self.windowed_iterable
        pattern_nodes = self.pattern_nodes
        new_iter_data = sortedmap()
        new_items = []

        if iterable is not None and len(pattern_nodes) > 0:
            for loop_index, loop_item in enumerate(iterable):
                iteration = old_iter_data.get(loop_item)
                if iteration is not None:
                    new_iter_data[loop_item] = iteration
                    new_items.append(iteration)
                    old_items.remove(iteration)
                    continue
                iteration = []
                new_iter_data[loop_item] = iteration
                new_items.append(iteration)
                for nodes, key, f_locals in pattern_nodes:
                    with new_scope(key, f_locals) as f_locals:
                        f_locals['loop_index'] = loop_index
                        f_locals['loop_item'] = loop_item
                        for node in nodes:
                            child = node(None)
                            if isinstance(child, list):
                                iteration.extend(child)
                            else:
                                iteration.append(child)
        
        # Add to old items list
        #self.old_items.extend(old_items)
        
        #if self._dirty:
        for iteration in old_items:
            for old in iteration:
                if not old.is_destroyed:
                    old.destroy()

        if len(new_items) > 0:
            expanded = []
            recursive_expand(sum(new_items, []), expanded)
            self.parent.insert_children(self, expanded)

        self.items = new_items# if self._dirty else new_items+old_items
        self._iter_data = new_iter_data
136087
public function rewind()
    {
        $this->current = null;
        foreach ($this->children as $item) {
            $item->rewind();
        }
        reset($this->children);
    }
369575
public function rewind()
    {
        if ($this->cursor !== null) {
            $this->cursor->rewind();
            return;
        }

        $this->cursor = $this->collection
            ->getMongoCollection()
            ->find(
                $this->expression->toArray(),
                $this->projection
            );

        if ($this->skip) {
            $this->cursor->skip($this->skip);
        }

        if ($this->limit) {
            $this->cursor->limit($this->limit);
        }

        if ($this->options['batchSize']) {
            $this->cursor->batchSize($this->options['batchSize']);
        }

        if ($this->options['clientTimeout']) {
            $this->cursor->timeout($this->options['clientTimeout']);
        }

        if ($this->options['serverTimeout']) {
            $this->cursor->maxTimeMS($this->options['clientTimeout']);
        }

        if (!empty($this->sort)) {
            $this->cursor->sort($this->sort);
        }

        if ($this->hint) {
            $this->cursor->hint($this->hint);
        }

        // define read preferences
        if (!empty($this->readPreference)) {
            $this->cursor->setReadPreference(
                $this->readPreference['type'],
                $this->readPreference['tagsets']
            );
        }

        // init cursor state
        $this->cursor->rewind();
    }
576150
function (collection, callback) {
        var index,
            iterable = collection,
            result = iterable;

        if (!iterable) {
            return result;
        }

        if (!sofa.Util.objectTypes[typeof iterable]) {
            return result;
        }

        for (index in iterable) {
            if (Object.prototype.hasOwnProperty.call(iterable, index)) {
                if (callback(iterable[index], index, collection) === false) {
                    return result;
                }
            }
        }
        return result;
    }
388291
public function rewind()
    {
        if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
            parent::rewind();

            return;
        }

        $iterator = $this;
        while ($iterator instanceof \OuterIterator) {
            $innerIterator = $iterator->getInnerIterator();

            if ($innerIterator instanceof RecursiveDirectoryIterator) {
                // this condition is necessary for iterators to work properly with non-local filesystems like ftp
                if ($innerIterator->isRewindable()) {
                    $innerIterator->next();
                    $innerIterator->rewind();
                }
            } elseif ($innerIterator instanceof \FilesystemIterator) {
                $innerIterator->next();
                $innerIterator->rewind();
            }

            $iterator = $innerIterator;
        }

        parent::rewind();
    }
1346802
function(collection){
	Array.apply(this);
	if(arguments.length >= 1){
		for(var i=0,len = collection.length;i<len;i++){
			var item = collection[i];
			if(this.indexOf(item) < 0){
				this.push(item);
			}
		}
	}
 }
784450
public function rewind()
    {
        // check that the hydration can begin
        if (null === $this->formatter) {
            throw new PropelException('The On Demand collection requires a formatter. Add it by calling setFormatter()');
        }
        if (null === $this->dataFetcher) {
            throw new PropelException('The On Demand collection requires a dataFetcher. Add it by calling setDataFetcher()');
        }
        if (null !== $this->isValid) {
            throw new PropelException('The On Demand collection can only be iterated once');
        }

        // initialize the current row and key
        $this->next();
    }
826331
def _rewind(self):
        ''''''
        DFReader._rewind(self)
        self.line = 0
        # find the first valid line
        while self.line < len(self.lines):
            if self.lines[self.line].startswith("FMT, "):
                break
            self.line += 1
78568
public function rewind()
    {
        if (null === $this->headerRowNumber) {
            $this->pointer = 0;
        } else {
            $this->pointer = $this->headerRowNumber + 1;
        }
    }
871342
def first(self, x):
        """"""

        def _find(x):
            try:
                return self.all.index(str(x))
            except ValueError:
                return None

        if _is_collection(x):
            for item in x:
                found = _find(item)
                if found is not None:
                    return found
            return None
        else:
            return _find(x)
413721
public function getFirst()
    {
        $varReturn = null;
        if (count($this->collection) > 0) {
            $varReturn = $this->collection[0];
        }

        return $varReturn;
    }
36073
def first(pipe, items=1):
    ''' 
    '''
    pipe = iter(pipe)
    return next(pipe) if items == 1 else islice(pipe, 0, items)
85099
public function rewind()
    {
        //echo 'r';
        $this->iterators->rewind();
        if (!$this->iterators->valid()) {
            $this->currentIterator = new ArrayIterator(array());
        } else {
            $this->currentIterator = $this->iterators->current();
        }
        $this->currentIterator->rewind();
    }