// For aggregates repeated calls to itself and calls f once every duration
// with the number of aggregated calls and the tag coalesced with the calling
// file and line number
420841
func For(duration time.Duration, id string, f func(int, string)) {
	// WrapFor is depth 1,
	WrapFor(2, duration, id, f)
}
1275235
func (ListISOs) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListISOsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListISOsResponse was expected, got %T", resp))
		return
	}

	for i := range items.ISO {
		if !callback(&items.ISO[i], nil) {
			break
		}
	}
}
329749
func WaitFor(timeout time.Duration, period time.Duration, f func() (bool, error)) error {
	timeoutChan := time.After(timeout)
	var (
		wait bool = true
		err  error
	)
	for wait {
		select {
		case <-timeoutChan:
			return fmt.Errorf("Timed out")
		default:
			wait, err = f()
			if err != nil {
				return err
			}
			time.Sleep(period)
		}
	}

	return nil
}
215702
func (p *Profile) Aggregate(inlineFrame, function, filename, linenumber, address bool) error {
	for _, m := range p.Mapping {
		m.HasInlineFrames = m.HasInlineFrames && inlineFrame
		m.HasFunctions = m.HasFunctions && function
		m.HasFilenames = m.HasFilenames && filename
		m.HasLineNumbers = m.HasLineNumbers && linenumber
	}

	// Aggregate functions
	if !function || !filename {
		for _, f := range p.Function {
			if !function {
				f.Name = ""
				f.SystemName = ""
			}
			if !filename {
				f.Filename = ""
			}
		}
	}

	// Aggregate locations
	if !inlineFrame || !address || !linenumber {
		for _, l := range p.Location {
			if !inlineFrame && len(l.Line) > 1 {
				l.Line = l.Line[len(l.Line)-1:]
			}
			if !linenumber {
				for i := range l.Line {
					l.Line[i].Line = 0
				}
			}
			if !address {
				l.Address = 0
			}
		}
	}

	return p.CheckValid()
}
1152908
func (g *Group) CallFunc(f func(*Group)) *Statement {
	s := CallFunc(f)
	g.items = append(g.items, s)
	return s
}
890961
func TagsFor(field reflect.StructField) Tags {
	pTags := Tags{}
	for _, tag := range strings.Fields(tags) {
		if valTag := field.Tag.Get(tag); valTag != "" {
			pTags = append(pTags, Tag{valTag, tag})
		}
	}

	if len(pTags) == 0 {
		pTags = append(pTags, Tag{field.Name, "db"})
	}
	return pTags
}
1286872
func (s Seq) Each(mapfn func(int, float64)) {
	for i := 0; i < s.Len(); i++ {
		mapfn(i, s.GetValue(i))
	}
}
1212813
func IterateParents(exp Expression, f func(Expression) bool) {
	if exp != nil {
		exp = exp.Parent()
	}
	for exp != nil {
		if !f(exp) {
			return
		}
		exp = exp.Parent()
	}
}
1091837
func (b *Buffer) Each(mapfn func(int, float64)) {
	if b.size == 0 {
		return
	}

	var index int
	if b.head < b.tail {
		for cursor := b.head; cursor < b.tail; cursor++ {
			mapfn(index, b.array[cursor])
			index++
		}
	} else {
		for cursor := b.head; cursor < len(b.array); cursor++ {
			mapfn(index, b.array[cursor])
			index++
		}
		for cursor := 0; cursor < b.tail; cursor++ {
			mapfn(index, b.array[cursor])
			index++
		}
	}
}
733569
func (c Collector) Each(fx StringEachfunc) {
	var state bool
	for k, v := range c {
		if state {
			break
		}

		fx(v, k, func() {
			state = true
		})
	}
}
137417
func (ListResourceDetails) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListResourceDetailsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListResourceDetailsResponse was expected, got %T", resp))
		return
	}

	for i := range items.ResourceDetail {
		if !callback(&items.ResourceDetail[i], nil) {
			break
		}
	}
}
841916
func (app *App) CacheFor(handler interface{}, ttl time.Duration) func(ctx *Context) {
	opts := app.getCacheOpts()

	opts.TTL = ttl
	return app.Cache(handler, opts)
}
182703
func Every(t time.Duration, f func()) *time.Ticker {
	ticker := time.NewTicker(t)

	go func() {
		for {
			select {
			case <-ticker.C:
				f()
			}
		}
	}()

	return ticker
}
415565
func (d *Devices) Each(f func(Device)) {
	for _, device := range *d {
		f(device)
	}
}
779726
func (h *Finder) Iterate(hash uint32, buf []byte, iterFunc func(int64) bool) (bool, error) {
	if h == nil || hash == 0 || len(buf) != h.size {
		return false, nil
	}

	for _, offset := range h.offsets[hash] {
		_, err := h.reader.Seek(offset, io.SeekStart)
		if err != nil {
			return false, err
		}
		_, err = h.reader.Read(buf)
		if err != nil {
			return false, err
		}
		if !iterFunc(offset) {
			return true, nil
		}
	}
	return false, nil
}
781861
func For(msg string, timeout, interval time.Duration, f func() (bool, error)) error {
	log.Infof("Wait for %s [timeout: %s, interval: %s]", msg, timeout, interval)

	var lastErr string
	timeUp := time.After(timeout)
	for {
		select {
		case <-timeUp:
			return fmt.Errorf("time limit exceeded: last error: %s", lastErr)
		default:
		}

		stop, err := f()
		if stop {
			return nil
		}
		if err != nil {
			lastErr = err.Error()
		}

		time.Sleep(interval)
	}
}
1327608
func (v *BlockValidation) ForBlock(blockHash string) bool {
	return blockHash != "" && blockHash == v.Hash
}