// iterateOverFirehoseHandlers applies the function f to all live firehose handlers
// and then resets the list to only include the live ones.
512927
func (g *gregorHandler) iterateOverFirehoseHandlers(f func(h libkb.GregorFirehoseHandler)) {
	var freshHandlers []libkb.GregorFirehoseHandler
	for _, h := range g.firehoseHandlers {
		if h.IsAlive() {
			f(h)
			freshHandlers = append(freshHandlers, h)
		}
	}
	g.firehoseHandlers = freshHandlers
	return
}
297431
func (s *FileSet) Iterate(f func(*File) bool) {
	for i := 0; ; i++ {
		var file *File
		s.mutex.RLock()
		if i < len(s.files) {
			file = s.files[i]
		}
		s.mutex.RUnlock()
		if file == nil || !f(file) {
			break
		}
	}
}
368478
func (s *SimpleFSHandler) SimpleFSListRecursiveToDepth(ctx context.Context, arg keybase1.SimpleFSListRecursiveToDepthArg) error {
	ctx, cancel := s.wrapContextWithTimeout(ctx)
	defer cancel()
	cli, err := s.client()
	if err != nil {
		return err
	}
	return cli.SimpleFSListRecursiveToDepth(ctx, arg)
}
1176571
func (w *WrappedRevelCallback) FireEvent(key Event, value interface{}) (response EventResponse) {
	if w.FireEventFunction != nil {
		response = w.FireEventFunction(key, value)
	}
	return
}
630561
func (ListEventTypes) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListEventTypesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListEventTypesResponse was expected, got %T", resp))
		return
	}

	for i := range items.EventType {
		if !callback(&items.EventType[i], nil) {
			break
		}
	}
}
989761
func (s *FirewallService) NewListPaloAltoFirewallsParams() *ListPaloAltoFirewallsParams {
	p := &ListPaloAltoFirewallsParams{}
	p.p = make(map[string]interface{})
	return p
}
1313792
func (f *FST) Iterator(startKeyInclusive, endKeyExclusive []byte) (*FSTIterator, error) {
	return newIterator(f, startKeyInclusive, endKeyExclusive, nil)
}
1264749
func (srv *StreamService) Firehose(params *StreamFirehoseParams) (*Stream, error) {
	req, err := srv.public.New().Get("firehose.json").QueryStruct(params).Request()
	if err != nil {
		return nil, err
	}
	return newStream(srv.client, req), nil
}
807756
func newTowerListIterator(candidates ...*wtdb.Tower) *towerListIterator {
	iter := &towerListIterator{
		candidates: list.New(),
	}

	for _, candidate := range candidates {
		iter.candidates.PushBack(candidate)
	}
	iter.Reset()

	return iter
}
589455
func (evc *EventCache) FireEvent(event string, data EventData) {
	// append to list (go will grow our backing array exponentially)
	evc.events = append(evc.events, eventInfo{event, data})
}
683027
func (s *SinkYARPCServer) WaitFireDone() error {
	if s.fireDone == nil {
		return nil
	}
	select {
	case <-s.fireDone:
	case <-time.After(FireDoneTimeout):
		return yarpcerrors.Newf(yarpcerrors.CodeDeadlineExceeded, "fire not done after %v", FireDoneTimeout)
	}
	return nil
}
808784
func (m *HashMap) Iter() <-chan KeyValue {
	ch := make(chan KeyValue) // do not use a size here since items can get added during iteration

	go func() {
		list := m.list()
		if list == nil {
			close(ch)
			return
		}
		item := list.First()
		for item != nil {
			value := item.Value()
			ch <- KeyValue{item.key, value}
			item = item.Next()
		}
		close(ch)
	}()

	return ch
}
269453
func (m ExtensionMechanismMap) Iter(fn func(string, Mechanism) bool) {
	for s, mechanism := range m {
		fn(s, mechanism)
	}
}
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
	})
}
1054265
func (c *CloudAPI) handleListFirewallRules(w http.ResponseWriter, r *http.Request, params httprouter.Params) error {
	rules, err := c.ListFirewallRules()
	if err != nil {
		return err
	}
	if rules == nil {
		rules = []*cloudapi.FirewallRule{}
	}
	return sendJSON(http.StatusOK, rules, w, r)
}
543250
func (a *APIDefinition) IterateUserTypes(it UserTypeIterator) error {
	names := make([]string, len(a.Types))
	i := 0
	for n := range a.Types {
		names[i] = n
		i++
	}
	sort.Strings(names)
	for _, n := range names {
		if err := it(a.Types[n]); err != nil {
			return err
		}
	}
	return nil
}
599515
func hasAnyNullIterators(its []graph.Iterator) bool {
	for _, it := range its {
		if it.Type() == graph.Null {
			return true
		}
	}
	return false
}