// iterateOverAllFrames iterates over every single frame in tag and calls
// f for them. It consumps no memory at all, unlike the tag.AllFrames().
// It returns error only if f returns error.
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
}
1091375
func (toks *Toks) Iterate(t *html.Node) {
	for _, tok := range *toks {
		if tok.Match(t.Type, t.DataAtom) {
			tok.Callback(t)
		}
	}
}
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
	})
}
1326183
func (buf *FloatBuffer) NumFrames() int {
	if buf == nil || buf.Format == nil {
		return 0
	}
	numChannels := buf.Format.NumChannels
	if numChannels == 0 {
		numChannels = 1
	}

	return len(buf.Data) / numChannels
}
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
	})
}
1132729
func (t *Tab) GetFrameDocuments() []*Element {
	frames := make([]*Element, 0)
	t.eleMutex.RLock()
	for _, ele := range t.elements {
		if ok, _ := ele.IsDocument(); ok {
			frames = append(frames, ele)
		}
	}
	t.eleMutex.RUnlock()
	return frames
}
1178769
func (fs *FS) AllProcs() Iter {
	procs, err := fs.FS.AllProcs()
	if err != nil {
		err = fmt.Errorf("Error reading procs: %v", err)
	}
	return &procIterator{procs: procfsprocs{procs, fs}, err: err, idx: -1}
}
368802
func DoAll(err error, f func(error)) {
	switch terr := err.(type) {
	case *errorBox:
		for _, serr := range Stack(err) {
			f(serr)
		}
	case *errorCollection:
		for _, aerr := range All(err) {
			f(aerr)
		}
	default:
		f(terr)
	}
}
549964
func AllTags(next NextTagFunction) []*Tag {
	tags := make([]*Tag, 0)

	tag, _ := next()
	for *tag != NoneTag {
		tags = append(tags, tag)
		tag, _ = next()
	}

	return tags
}
908190
func (m *MediaTypeDefinition) IterateViews(it ViewIterator) error {
	o := m.Views
	// gather names and sort them
	names := make([]string, len(o))
	i := 0
	for n := range o {
		names[i] = n
		i++
	}
	sort.Strings(names)
	// iterate
	for _, n := range names {
		if err := it(o[n]); err != nil {
			return err
		}
	}
	return nil
}
1304541
func (e *Error) Stack() string {
	if len(e.stacks) > 0 {
		var frames []string
		for _, stack := range e.stacks {
			if frames == nil {
				frames = make([]string, 0, len(stack))
			} else {
				frames = append(frames, "----- attached stack -----")
			}
			for _, f := range stack {
				frames = append(frames, f.String())
			}
		}
		return strings.Join(frames, "\n")
	}
	return ""
}
544718
func (d *iterData) iterate(node *treeNode) bool {
	var proceed bool

	if node.left != nil {
		proceed = d.iterate(node.left)
		if !proceed {
			return false
		}
	}

	proceed = d.iter(node.value)
	if !proceed {
		return false
	}

	if node.right != nil {
		proceed = d.iterate(node.right)
		if !proceed {
			return false
		}
	}

	return true
}
796646
func (a *APIDefinition) IterateSets(iterator dslengine.SetIterator) {
	// First run the top level API DSL to initialize responses and
	// response templates needed by resources.
	iterator([]dslengine.Definition{a})

	// Then run the user type DSLs
	typeAttributes := make([]dslengine.Definition, len(a.Types))
	i := 0
	a.IterateUserTypes(func(u *UserTypeDefinition) error {
		u.AttributeDefinition.DSLFunc = u.DSLFunc
		typeAttributes[i] = u.AttributeDefinition
		i++
		return nil
	})
	iterator(typeAttributes)

	// Then the media type DSLs
	mediaTypes := make([]dslengine.Definition, len(a.MediaTypes))
	i = 0
	a.IterateMediaTypes(func(mt *MediaTypeDefinition) error {
		mediaTypes[i] = mt
		i++
		return nil
	})
	iterator(mediaTypes)

	// Then, the Security schemes definitions
	var securitySchemes []dslengine.Definition
	for _, scheme := range a.SecuritySchemes {
		securitySchemes = append(securitySchemes, dslengine.Definition(scheme))
	}
	iterator(securitySchemes)

	// And now that we have everything - the resources. The resource
	// lifecycle handlers dispatch to their children elements, like Actions,
	// etc.. We must process parent resources first to ensure that query
	// string and path parameters are initialized by the time a child
	// resource action parameters are categorized.
	resources := make([]*ResourceDefinition, len(a.Resources))
	i = 0
	a.IterateResources(func(res *ResourceDefinition) error {
		resources[i] = res
		i++
		return nil
	})
	sort.Sort(byParent(resources))
	defs := make([]dslengine.Definition, len(resources))
	for i, r := range resources {
		defs[i] = r
	}
	iterator(defs)
}
610704
func Iterate(g func() Streamer) Streamer {
	var (
		s     Streamer
		first = true
	)
	return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
		if first {
			s = g()
			first = false
		}
		if s == nil {
			return 0, false
		}
		for len(samples) > 0 {
			if s == nil {
				break
			}
			sn, sok := s.Stream(samples)
			if !sok {
				s = g()
			}
			samples = samples[sn:]
			n += sn
		}
		return n, true
	})
}
155978
func (s *H264Settings) SetNumberBFramesBetweenReferenceFrames(v int64) *H264Settings {
	s.NumberBFramesBetweenReferenceFrames = &v
	return s
}
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()
}
531939
func (tag *Tag) DeleteFrames(id string) {
	delete(tag.frames, id)
	if s, ok := tag.sequences[id]; ok {
		putSequence(s)
		delete(tag.sequences, id)
	}
}