// ForEach calls the function for each row returned by the query
// without loading all rows into the memory.
// Function accepts a struct, pointer to a struct, orm.Model,
// or values for columns in a row. Function must return an error.
190334
func (q *Query) ForEach(fn interface{}) error {
	m := newFuncModel(fn)
	return q.Select(m)
}
287912
func (f *fragment) forEachBit(fn func(rowID, columnID uint64) error) error {
	f.mu.Lock()
	defer f.mu.Unlock()

	var err error
	f.storage.ForEach(func(i uint64) {
		// Skip if an error has already occurred.
		if err != nil {
			return
		}

		// Invoke caller's function.
		err = fn(i/ShardWidth, (f.shard*ShardWidth)+(i%ShardWidth))
	})
	return err
}
1292405
func (tx *Tx) ForEach(fn func(name []byte, b *Bucket) error) error {
	return tx.root.ForEach(func(k, v []byte) error {
		if err := fn(k, tx.root.Bucket(k)); err != nil {
			return err
		}
		return nil
	})
}
934456
func (s *Service) forEachUser(ctx context.Context, tx Tx, fn func(*influxdb.User) bool) error {
	b, err := s.userBucket(tx)
	if err != nil {
		return err
	}

	cur, err := b.Cursor()
	if err != nil {
		return ErrInternalUserServiceError(err)
	}

	for k, v := cur.First(); k != nil; k, v = cur.Next() {
		u, err := UnmarshalUser(v)
		if err != nil {
			return err
		}
		if !fn(u) {
			break
		}
	}

	return nil
}
35167
func Each(array []interface{}, iterator Iterator) {
	for index, data := range array {
		iterator(data, index)
	}
}
261431
func (h *HTMLElement) ForEach(goquerySelector string, callback func(int, *HTMLElement)) {
	i := 0
	h.DOM.Find(goquerySelector).Each(func(_ int, s *goquery.Selection) {
		for _, n := range s.Nodes {
			callback(i, NewHTMLElementFromSelectionNode(h.Response, s, n, i))
			i++
		}
	})
}
1342431
func (q Query) ForEachT(actionFn interface{}) {
	actionGenericFunc, err := newGenericFunc(
		"ForEachT", "actionFn", actionFn,
		simpleParamValidator(newElemTypeSlice(new(genericType)), nil),
	)

	if err != nil {
		panic(err)
	}

	actionFunc := func(item interface{}) {
		actionGenericFunc.Call(item)
	}

	q.ForEach(actionFunc)
}
723869
func (s rwsetKeys) foreach(f func(key rwSetKey)) {
	for k := range s {
		f(k)
	}
}
623146
func (e *EndpointSet) ForEach(wg *sync.WaitGroup, epFunc func(epp Endpoint)) {
	e.mutex.Lock()
	defer e.mutex.Unlock()

	wg.Add(len(e.endpoints))

	for ep := range e.endpoints {
		go func(eppp Endpoint) {
			epFunc(eppp)
			wg.Done()
		}(ep)
	}
}
710502
func (pb *Packbuilder) ForEach(callback PackbuilderForeachCallback) error {
	data := packbuilderCbData{
		callback: callback,
		err:      nil,
	}
	handle := pointerHandles.Track(&data)
	defer pointerHandles.Untrack(handle)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	err := C._go_git_packbuilder_foreach(pb.ptr, handle)
	runtime.KeepAlive(pb)
	if err == C.GIT_EUSER {
		return data.err
	}
	if err < 0 {
		return MakeGitError(err)
	}

	return nil
}
743882
func forEachUser(ctx context.Context, tx *bolt.Tx, fn func(*platform.User) bool) error {
	cur := tx.Bucket(userUser).Cursor()
	for k, v := cur.First(); k != nil; k, v = cur.Next() {
		u := &platform.User{}
		if err := json.Unmarshal(v, u); err != nil {
			return err
		}
		if !fn(u) {
			break
		}
	}

	return nil
}
1098193
func (t *Immutable) ForEach(fn func(k, v []byte) bool) {
	// Add the root node and all children to the left of it to the list of
	// nodes to traverse and loop until they, and all of their child nodes,
	// have been traversed.
	var parents parentStack
	for node := t.root; node != nil; node = node.left {
		parents.Push(node)
	}
	for parents.Len() > 0 {
		node := parents.Pop()
		if !fn(node.key, node.value) {
			return
		}

		// Extend the nodes to traverse by all children to the left of
		// the current node's right child.
		for node := node.right; node != nil; node = node.left {
			parents.Push(node)
		}
	}
}
1275995
func (iter *ReferenceSliceIter) ForEach(cb func(*plumbing.Reference) error) error {
	return forEachReferenceIter(iter, cb)
}
100592
func (m *MapSpec) ForEachTypeReference(f func(TypeSpec) error) error {
	if err := f(m.KeySpec); err != nil {
		return err
	}
	return f(m.ValueSpec)
}
88095
func (iter *MultiReferenceIter) ForEach(cb func(*plumbing.Reference) error) error {
	return forEachReferenceIter(iter, cb)
}
502961
func (iter *MultiEncodedObjectIter) ForEach(cb func(plumbing.EncodedObject) error) error {
	return ForEachIterator(iter, cb)
}
1105854
func (s *set) Foreach(f func(*Term)) {
	s.Iter(func(t *Term) error {
		f(t)
		return nil
	})
}