// Iterate calls the Iteratee func for every item in the Value.
767149
func Iterate(val Value, it Iteratee) (int, error) {
	if val == nil {
		return 0, nil
	}
	r := reflect.Indirect(reflect.ValueOf(val))
	switch r.Kind() {
	case reflect.Slice, reflect.Array:
		ln := r.Len()
		l := Loop{ln == 1, 1, 0}
		for i := 0; i < ln; i++ {
			v := r.Index(i)
			brk, err := it(i, v.Interface(), l)
			if brk || err != nil {
				return i + 1, err
			}

			l.Index++
			l.Index0++
			l.Last = ln == l.Index
		}
		return ln, nil
	case reflect.Map:
		keys := r.MapKeys()
		ln := r.Len()
		l := Loop{ln == 1, 1, 0}
		for i, k := range keys {
			v := r.MapIndex(k)
			brk, err := it(k.Interface(), v.Interface(), l)
			if brk || err != nil {
				return i + 1, err
			}

			l.Index++
			l.Index0++
			l.Last = ln == l.Index
		}
		return ln, nil
	default:
		return 0, fmt.Errorf(`stick: unable to iterate over %s "%v"`, r.Kind(), val)
	}
}
176142
func (c *IterateChain) All() ([]Value, error) {
	c.start()
	defer c.end()
	done := c.ctx.Done()
	var out []Value
iteration:
	for c.next() {
		select {
		case <-done:
			break iteration
		default:
		}
		out = append(out, c.it.Result())
		for c.nextPath() {
			select {
			case <-done:
				break iteration
			default:
			}
			out = append(out, c.it.Result())
		}
	}
	return out, c.it.Err()
}
548551
func (o Object) IterateAttributes(it AttributeIterator) error {
	names := make([]string, len(o))
	i := 0
	for n := range o {
		names[i] = n
		i++
	}
	sort.Strings(names)
	for _, n := range names {
		if err := it(n, o[n]); err != nil {
			return err
		}
	}
	return nil
}
962556
func (b *Bitmap) Iterator() *Iterator {
	itr := &Iterator{bitmap: b}
	itr.Seek(0)
	return itr
}
460273
func (engine *Engine) Iterate(bean interface{}, fun IterFunc) error {
	session := engine.NewSession()
	defer session.Close()
	return session.Iterate(bean, fun)
}
161090
func (kv *KV) Iterator(f func([]byte, []byte) bool) error {
	return kv.db.View(func(txn *badger.Txn) error {
		opts := badger.DefaultIteratorOptions
		opts.PrefetchSize = 10
		it := txn.NewIterator(opts)
		defer it.Close()
		for it.Rewind(); it.Valid(); it.Next() {
			item := it.Item()
			if k := item.Key(); k != nil {
				v, err := item.Value()
				if err != nil {
					return err
				}
				if !f(k, v) {
					break
				}
			}
		}
		return nil
	})
}
751302
func (iter *Iterator) Seek(key []byte) bool {
	iter.isNew = false
	return iter.seek(key, true, true)
}
610271
func (s *set) Each(f func(item interface{}) bool) {
	for item := range s.m {
		if !f(item) {
			break
		}
	}
}
836532
func (f *StringForwarder) loop(callback func(string)) {
	f.mu.Lock()
	defer f.mu.Unlock()
	for {
		for !f.stopped && f.current == nil {
			f.cond.Wait()
		}
		if f.current == nil {
			return
		}
		f.invokeCallback(callback, *f.current)
		f.current = nil
	}
}
449100
func (kv *KV) Iterator(f func([]byte, []byte) bool) error {
	rows, err := kv.db.Query(
		fmt.Sprintf("SELECT k, v FROM %s", string(kv.table)),
	)
	if err != nil {
		return err
	}
	defer rows.Close()
	var k, v []byte
	for rows.Next() {
		if err = rows.Scan(&k, &v); err == nil {
			if !f(k, v) {
				break
			}
		}
	}
	return err
}
186832
func (ListZones) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListZonesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListZonesResponse was expected, got %T", resp))
		return
	}

	for i := range items.Zone {
		if !callback(&items.Zone[i], nil) {
			break
		}
	}
}
666233
func (c *Collection) Iterator(pivot gtreap.Item) *gtreap.Iterator {
	root := c.currentRoot()
	if root == nil {
		root = emptyTreap
	}
	return root.Iterator(pivot)
}
259403
func (cdb *CDB) Iter() *Iterator {
	return &Iterator{
		db:     cdb,
		pos:    uint32(indexSize),
		endPos: cdb.index[0].offset,
	}
}
80216
func (i *Index) IterateSimilar(input string, min float64, limit int) <-chan MatchResult {
  c := make(chan MatchResult)
  go i.iterateSimilar(c, input, min, limit)
  return c
}
104468
func (ListUsers) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListUsersResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListUsersResponse was expected, got %T", resp))
		return
	}

	for i := range items.User {
		if !callback(&items.User[i], nil) {
			break
		}
	}
}
1376
func Iterate(ctx context.Context, it Iterator) *IterateChain {
	if ctx == nil {
		ctx = context.Background()
	}
	return &IterateChain{
		ctx: ctx, it: it,
		limit: -1, paths: true,
		optimize: true,
	}
}
959232
func (kv *KV) Iterator(f func([]byte, []byte) bool) error {
	return kv.db.View(func(tx *buntdb.Tx) error {
		err := tx.Ascend("", func(key, value string) bool {
			return f(gkv.Stob(key), gkv.Stob(value))
		})
		return err
	})
}