// fetching elements with a given prefix.
// handle is called with arguments key and value (if handle returns `false`, the iteration is aborted)
332906
func (t *Trie) Allprefixed(prefix []byte, handle func(key []byte, value interface{}) bool) bool {
	// an empty tree
	if t.size == 0 {
		return true
	}

	// walk tree, maintaining top pointer
	p := &t.root
	top := p
	if len(prefix) > 0 {
		for q := p.internal; q != nil; q = p.internal {
			p = &q.child[q.direction(prefix)]
			if q.offset < len(prefix) {
				top = p
			}
		}

		// check prefix
		if !bytes.Contains(p.external.key, prefix) {
			return true
		}
	}

	return allprefixed(top, handle)
}
1068471
func (eh guildEmojisUpdateEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*GuildEmojisUpdate); ok {
		eh(s, t)
	}
}
128720
func (g *routeGroup) Handle(method string, path string, h ...Handler) {
	g.handle(method, path, h)
}
1363244
func Handle(handler Handler, err error) {
	if err != nil {
		handler.Handle(err)
	}
}
520320
func (m *VHostManager) Handle(httphost string, w http.ResponseWriter, r *http.Request) bool {
	m.mu.RLock()
	defer m.mu.RUnlock()

	// For a request to "xyz.domain.com" See if we have a vhost handler for
	// either "xyz.domain.com" or "xyz"
	subdomain := strings.Split(httphost, ".")[0]
	return m.handle(httphost, w, r) || m.handle(subdomain, w, r)
}
515443
func (n *Node) handle() {
	resp := &Response{}
	for n.state == stateReady {
		err := n.codec.DecodeHead(&resp.Head)
		if err != nil {
			if n.state != stateShutdown {
				n.logger.Error("client > failed to decode head: ", err)
				n.Close()
			}
			break
		}

		if resp.Head.ID == 0 {
			n.heartbeat()
			continue
		}

		c := n.calls.Find(resp.Head.ID)
		if c == nil { // unknown response or request is timeout.
			n.codec.DiscardResult()
			n.logger.Error("client > unknown request: ", resp.Head.ID)
			continue
		}

		resp.Result.Value = c.reply
		err = n.codec.DecodeResult(&resp.Result)
		if err != nil {
			n.logger.Error("client > failed to decode result: ", err)
		} else if resp.Result.Error != nil {
			err = resp.Result.Error
		}
		c.finish(err)
	}

	n.calls.Clear(func(c *Call) {
		c.finish(ErrNodeShutdown)
	})
}
610142
func (w *TimeWait) handle() {
	var state int64
	atomic.StoreInt64(&state, 0)

	go func() {
		<-w.closer
		atomic.StoreInt64(&state, 1)
	}()

	for {
		time.Sleep(w.ms)

		bit := atomic.LoadInt64(&state)
		if bit > 0 {
			break
		}

		w.Done()
	}
}
1034839
func Handle(req *http.Request, h http.HandlerFunc, t *testing.T) {

	rr := httptest.NewRecorder()

	handler := http.HandlerFunc(h)

	handler.ServeHTTP(rr, req)

	if status := rr.Code; status != http.StatusOK {
		t.Errorf("handler returned wrong status code: got %v want %v",
			status, http.StatusOK)
	}
}
1191413
func (h HandlerFunc) Handle(ctx *Context, res *http.Response, err error) {
	h(ctx, res, err)
}
1145519
func Handle(pattern string, fn interface{}) {
	elems := strings.Split(pattern, "/")
	n := len(elems)
	if n == 0 {
		panic("empty pattern")
	}
	if n >= 2 && elems[n-2] == "{" && strings.HasSuffix(elems[n-1], "}") {
		elems[n-2] += "/" + elems[n-1]
		n--
		elems = elems[:n]
	}

	var vars []string
	re := "^"
	for i, elem := range elems {
		if i > 0 {
			re += "/"
		}
		wildcard := false
		if strings.HasPrefix(elem, "{") && strings.HasSuffix(elem, "}") {
			elem = elem[1 : len(elem)-1]
			wildcard = true
		}
		if strings.ContainsAny(elem, "{}") {
			panic("invalid pattern: " + pattern)
		}
		if i == 0 {
			if wildcard {
				panic("wildcard not allowed for host")
			}
			if elem == "" {
				re += "[^/]*"
			} else {
				re += `(?:[^/]+\.)?` + regexp.QuoteMeta(elem)
			}
			continue
		}
		if wildcard {
			if i == len(elems)-1 && strings.HasPrefix(elem, "/") {
				elem = elem[1:]
				re += "(.*)"
			} else {
				re += "([^/]+)"
			}
			vars = append(vars, elem)
		} else {
			re += regexp.QuoteMeta(elem)
		}
	}
	re += "$"

	h := &handler{
		regexp.MustCompile(re),
		vars,
		nil,
		fn,
	}

	fmt.Printf("h %s\n", re)

	if len(vars) > 0 {
		h.isVar = make(map[string]bool)
		for _, v := range vars {
			h.isVar[v] = true
		}
	}

	handlers = append(handlers, h)
}
242416
func (mux *TypeMux) Handle(t Type, h Handler) {
	mux.mux.Handle(TypeMatcher(t), h)
}
254732
func (c *managedHandleImpl) Handle() (interface{}, error) {
	if atomic.LoadInt32(&c.isActive) == 0 {
		return c.handle, errors.New("Resource handle is no longer valid")
	}
	return c.handle, nil
}
425739
func (h HandlerFunc) Handle(event json.RawMessage, ctx *Context) (interface{}, error) {
	return h(event, ctx)
}
206471
func (mux *ServeMux) Handle(pattern string, handler Handler) {
	for pattern != "" && pattern[0] == '/' {
		pattern = pattern[1:]
	}

	if pattern == "" {
		panic("http: invalid pattern " + pattern)
	}
	if handler == nil {
		panic("http: nil handler")
	}

	mux.m[pattern] = muxEntry{h: handler, pattern: pattern}
}
939948
func (eh relationshipAddEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*RelationshipAdd); ok {
		eh(s, t)
	}
}
562205
func (eh userUpdateEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*UserUpdate); ok {
		eh(s, t)
	}
}
67404
func (p *podEvaluator) Handles(a admission.Attributes) bool {
	op := a.GetOperation()
	if op == admission.Create {
		return true
	}
	return false
}