// iteration over encoded pcdata tables.
421922
func getvarint(pp *[]uint8) uint32 {
	var p []uint8
	var shift int
	var v uint32
	v = 0
	p = []uint8(*pp)
	for shift = 0; ; shift += 7 {
		v |= uint32(p[0]&0x7F) << uint(shift)
		tmp7 := p
		p = p[1:]
		if tmp7[0]&0x80 == 0 {
			break
		}
	}
	*pp = p
	return v
}
130355
func (u *User) Iterator() <-chan Tuple {
	ch := make(chan Tuple)
	go func() {
		u.RLock()
		for key, val := range u.data {
			ch <- Tuple{key, val}
		}
		u.RUnlock()
		close(ch)
	}()
	return ch
}
284954
func (r *AllocationBitmap) ForEach(fn func(int)) {
	r.lock.Lock()
	defer r.lock.Unlock()

	words := r.allocated.Bits()
	for wordIdx, word := range words {
		bit := 0
		for word > 0 {
			if (word & 1) != 0 {
				fn((wordIdx * wordSize * 8) + bit)
				word = word &^ 1
			}
			bit++
			word = word >> 1
		}
	}
}
731191
func Iterate(p *dt.Plugin, label string, opts OptsIterate) []dt.State {
	if len(label) == 0 {
		label = "__iterableStart"
	}
	return []dt.State{
		{
			Label: label,
			OnEntry: func(in *dt.Msg) string {
				var ss []string
				mem := p.GetMemory(in, opts.IterableMemKey)
				if len(mem.Val) == 0 {
					mem.Val = []byte(`[]`)
				}
				err := json.Unmarshal(mem.Val, &ss)
				if err != nil {
					p.Log.Info("failed to get iterable memory.", err)
					return ""
				}
				if len(ss) == 0 {
					return "I'm afraid I couldn't find any results like that."
				}
				var idx int64
				if p.HasMemory(in, keySelection) {
					idx = p.GetMemory(in, keySelection).Int64() + 1
				}
				if idx >= int64(len(ss)) {
					return "I'm afraid that's all I have."
				}
				p.SetMemory(in, keySelection, idx)
				return fmt.Sprintf("How about %s?", ss[idx])
			},
			OnInput: func(in *dt.Msg) {
				yes, err := language.ExtractYesNo(in.Sentence)
				if err != nil {
					// Yes/No answer not found
					return
				}
				if yes {
					idx := p.GetMemory(in, keySelection).Int64()
					p.SetMemory(in, opts.ResultMemKeyIdx, idx)
					return
				}
				// TODO handle "next", "something else", etc.
			},
			Complete: func(in *dt.Msg) (bool, string) {
				if p.HasMemory(in, opts.ResultMemKeyIdx) {
					return true, ""
				}
				return false, p.SM.ReplayState(in)
			},
		},
	}
}
1232478
func ConvertIterations(request *http.Request, Iterations []iteration.Iteration, additional ...IterationConvertFunc) []*app.Iteration {
	var is = []*app.Iteration{}
	for _, i := range Iterations {
		is = append(is, ConvertIteration(request, i, additional...))
	}
	return is
}
186401
func (jt *Type) encodeData(data interface{}) ([]byte, error) {
	// Check the type of data
	dataType := reflect.TypeOf(data)
	if dataType != jt.dataType {
		return nil, fmt.Errorf("jobs: provided data was not of the correct type.\nExpected %s for Type %s, but got %s", jt.dataType, jt, dataType)
	}
	// Encode the data
	encodedData, err := encode(data)
	if err != nil {
		return nil, fmt.Errorf("jobs: error encoding data: %s", err.Error())
	}
	return encodedData, nil
}
1091375
func (toks *Toks) Iterate(t *html.Node) {
	for _, tok := range *toks {
		if tok.Match(t.Type, t.DataAtom) {
			tok.Callback(t)
		}
	}
}
723869
func (s rwsetKeys) foreach(f func(key rwSetKey)) {
	for k := range s {
		f(k)
	}
}
322345
func (tag *Tag) iterateOverAllFrames(f func(id string, frame Framer) error) error {
	for id, frame := range tag.frames {
		if err := f(id, frame); err != nil {
			return err
		}
	}
	for id, sequence := range tag.sequences {
		for _, frame := range sequence.Frames() {
			if err := f(id, frame); err != nil {
				return err
			}
		}
	}
	return nil
}
1175376
func (iter *EncodedObjectSliceIter) ForEach(cb func(plumbing.EncodedObject) error) error {
	return ForEachIterator(iter, cb)
}
343573
func (cache *Cache) IterateCachedStorage(address crypto.Address,
	consumer func(key, value binary.Word256) error) error {
	accInfo, err := cache.get(address)
	if err != nil {
		return err
	}
	accInfo.RLock()
	// Try cache first for early exit
	for key, value := range accInfo.storage {
		if err := consumer(key, value); err != nil {
			accInfo.RUnlock()
			return err
		}
	}
	accInfo.RUnlock()
	return err
}
308162
func IterateReservedIdentities(f func(key string, value NumericIdentity)) {
	for key, value := range reservedIdentities {
		f(key, value)
	}
}
142880
func (t *Table) AppendData(rec map[string]interface{}) *Table {
	t.Data = append(t.Data, rec)
	return t
}
1020834
func (iter *TagIter) ForEach(cb func(*Tag) error) error {
	return iter.EncodedObjectIter.ForEach(func(obj plumbing.EncodedObject) error {
		t, err := DecodeTag(iter.s, obj)
		if err != nil {
			return err
		}

		return cb(t)
	})
}
931091
func (idx *TruncIndex) Iterate(handler func(id string)) {
	idx.Lock()
	defer idx.Unlock()
	idx.trie.Visit(func(prefix patricia.Prefix, item patricia.Item) error {
		handler(string(prefix))
		return nil
	})
}
79509
func (t *ImmutableTree) Iterate(fn func(key []byte, value []byte) bool) (stopped bool) {
	if t.root == nil {
		return false
	}
	return t.root.traverse(t, true, func(node *Node) bool {
		if node.height == 0 {
			return fn(node.key, node.value)
		}
		return false
	})
}
541766
func (iter *ObjectIter) ForEach(cb func(Object) error) error {
	return iter.EncodedObjectIter.ForEach(func(obj plumbing.EncodedObject) error {
		o, err := iter.toObject(obj)
		if err == plumbing.ErrInvalidType {
			return nil
		}

		if err != nil {
			return err
		}

		return cb(o)
	})
}