// forEachAccount calls the given function with each account stored in the
// manager, breaking early on error.
973075
func forEachAccount(ns walletdb.ReadBucket, scope *KeyScope,
	fn func(account uint32) error) error {

	scopedBucket, err := fetchReadScopeBucket(ns, scope)
	if err != nil {
		return err
	}

	acctBucket := scopedBucket.NestedReadBucket(acctBucketName)
	return acctBucket.ForEach(func(k, v []byte) error {
		// Skip buckets.
		if v == nil {
			return nil
		}
		return fn(binary.LittleEndian.Uint32(k))
	})
}
1175376
func (iter *EncodedObjectSliceIter) ForEach(cb func(plumbing.EncodedObject) error) error {
	return ForEachIterator(iter, cb)
}
6168
func (db *DB) SaveAccount(model AccountModel) {
	db.Lock()
	defer db.Unlock()
	db.accounts[model.ID] = &model
}
190334
func (q *Query) ForEach(fn interface{}) error {
	m := newFuncModel(fn)
	return q.Select(m)
}
565873
func (c *StashCollection) Foreach(callback StashCallback) error {
	data := stashCallbackData{
		Callback: callback,
	}

	handle := pointerHandles.Track(&data)
	defer pointerHandles.Untrack(handle)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C._go_git_stash_foreach(c.repo.ptr, handle)
	runtime.KeepAlive(c)
	if ret == C.GIT_EUSER {
		return data.Error
	}
	if ret < 0 {
		return MakeGitError(ret)
	}
	return nil
}
354626
func (s *Server) ForEachConn(f func(Conn)) {
	s.locker.Lock()
	defer s.locker.Unlock()
	for conn := range s.conns {
		f(conn)
	}
}
820377
func (s *Service) forEachVariable(ctx context.Context, tx Tx, fn func(*influxdb.Variable) bool) error {
	b, err := tx.Bucket(variableBucket)
	if err != nil {
		return err
	}

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

	for k, v := cur.First(); k != nil; k, v = cur.Next() {
		m := &influxdb.Variable{}
		if err := json.Unmarshal(v, m); err != nil {
			return err
		}
		if !fn(m) {
			break
		}
	}

	return nil
}
127584
func (obj *object) Foreach(f func(*Term, *Term)) {
	obj.Iter(func(k, v *Term) error {
		f(k, v)
		return nil
	})
}
133567
func (c *C) ForEach(fn func(int, []byte) bool) error {
	c.m.Lock()
	defer c.m.Unlock()
	f, err := c.file()
	if err != nil {
		return err
	}
	f.Seek(0, os.SEEK_SET)
	s := bufio.NewScanner(f)
	i := 0
	for s.Scan() {
		if fn(i, s.Bytes()) {
			break
		}
		i++
	}
	if s.Err() != nil {
		return s.Err()
	}
	return nil
}
298092
func (m *logMeasurement) forEach(fn func(tsdb.SeriesID)) {
	if m.seriesSet != nil {
		m.seriesSet.ForEachNoLock(fn)
		return
	}

	for seriesID := range m.series {
		fn(seriesID)
	}
}
474735
func (b *Bucket) forEachPage(fn func(*page, int)) {
	// If we have an inline page then just use that.
	if b.page != nil {
		fn(b.page, 0)
		return
	}

	// Otherwise traverse the page hierarchy.
	b.tx.forEachPage(b.root, 0, fn)
}
1047001
func (c *Client) forEachVariable(ctx context.Context, tx *bolt.Tx, fn func(*platform.Variable) bool) error {
	cur := tx.Bucket(variableBucket).Cursor()
	for k, v := cur.First(); k != nil; k, v = cur.Next() {
		m := &platform.Variable{}
		if err := json.Unmarshal(v, m); err != nil {
			return err
		}
		if !fn(m) {
			break
		}
	}

	return nil
}
303730
func Foreach(kv KeyValue, fn func(key, value string) error) error {
	return ForeachInRange(kv, "", "", fn)
}
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
	})
}
632868
func (c *Users) GetAccount(in *GetAccountInput) (out *GetAccountOutput, err error) {
	body, err := c.call("/users/get_account", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}
1010651
func (c *TagsCollection) Foreach(callback TagForeachCallback) error {
	data := tagForeachData{
		callback: callback,
		err:      nil,
	}

	handle := pointerHandles.Track(&data)
	defer pointerHandles.Untrack(handle)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

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

	return nil
}
1358213
func (c *Context) ForEach(fn func(k string, v interface{}) interface{}) []interface{} {
	c.lock.RLock()
	defer c.lock.RUnlock()

	ret := make([]interface{}, 0, len(c.contextMap))
	for k, v := range c.contextMap {
		ret = append(ret, fn(k, v))
	}

	return ret
}