// BFS performs a breadth first traversal calling f for each node starting from
// u. If f returns true, traversal stops and BFS returns true.
189817
func BFS(t Traversal, f Iter, u T) bool {
	fifo := NewFIFO(u)
	for fifo.Size() > 0 {
		next, _ := fifo.Pop()
		if t.Visited(next) {
			continue
		}
		if f(next) {
			return true
		}
		for _, v := range t.Edges(next) {
			fifo.Push(v)
		}
	}
	return false
}
186098
func (g Graph) SubgraphWithNodes(nodes []graph.Node, fn EdgeFunc) Graph {
	out := New()
	for _, node := range nodes {
		out.internal.AddNode(node)
	}
	out.addEdges(g.internal.Edges(), fn)
	return out
}
1174484
func newFST(inputType InputType, outputs Outputs, willPackFST bool,
	acceptableOverheadRatio float32, allowArrayArcs bool,
	bytesPageBits int) *FST {
	bytes := newBytesStoreFromBits(uint32(bytesPageBits))
	// pad: ensure no node gets address 0 which is reserved to mean
	// the stop state w/ no arcs
	bytes.WriteByte(0)
	ans := &FST{
		inputType:      inputType,
		outputs:        outputs,
		allowArrayArcs: allowArrayArcs,
		version:        VERSION_CURRENT,
		bytes:          bytes,
		NO_OUTPUT:      outputs.NoOutput(),
		startNode:      -1,
	}
	if willPackFST {
		ans.nodeAddress = packed.NewGrowableWriter(15, 8, acceptableOverheadRatio)
		ans.inCounts = packed.NewGrowableWriter(1, 8, acceptableOverheadRatio)
	}
	return ans
}
215887
func getParentsNodes(nodes []*html.Node, stopm Matcher, stopNodes []*html.Node) []*html.Node {
	return mapNodes(nodes, func(i int, n *html.Node) (result []*html.Node) {
		for p := n.Parent; p != nil; p = p.Parent {
			sel := newSingleSelection(p, nil)
			if stopm != nil {
				if sel.IsMatcher(stopm) {
					break
				}
			} else if len(stopNodes) > 0 {
				if sel.IsNodes(stopNodes...) {
					break
				}
			}
			if p.Type == html.ElementNode {
				result = append(result, p)
			}
		}
		return
	})
}
368657
func btreeStats(us []uint32) (BTreeStats, error) {
	if l := len(us); l != 4 {
		return BTreeStats{}, fmt.Errorf("incorrect number of values for XFS btree stats: %d", l)
	}

	return BTreeStats{
		Lookups:         us[0],
		Compares:        us[1],
		RecordsInserted: us[2],
		RecordsDeleted:  us[3],
	}, nil
}
65346
func WalkNodes(n *exphtml.Node, f func(*exphtml.Node)) {
	if n != nil {
		f(n)
		for c := n.FirstChild; c != nil; c = c.NextSibling {
			WalkNodes(c, f)
		}
	}
}
280518
func NewBFlags() *BFlags {
	return &BFlags{
		flags: make(map[string]*Flag),
		used:  make(map[string]*Flag),
	}
}
496632
func (d *domainClient) PushNodesByBackendIDsToFrontend(ctx context.Context, args *PushNodesByBackendIDsToFrontendArgs) (reply *PushNodesByBackendIDsToFrontendReply, err error) {
	reply = new(PushNodesByBackendIDsToFrontendReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "DOM.pushNodesByBackendIdsToFrontend", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "DOM.pushNodesByBackendIdsToFrontend", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "DOM", Op: "PushNodesByBackendIDsToFrontend", Err: err}
	}
	return
}
1268609
func FuzzReadSubTreesNoProof(data []byte) int {
	buildAndCompareTreesFromFuzz(data, math.MaxUint64)
	if len(data) > 2 {
		return 1
	}
	return 0
}
339435
func (b *BreadthFirst) Reset() {
	b.queue.Reset()
	if b.visited != nil {
		b.visited.Clear()
	}
}
1306739
func ParseBasic(s string) map[string]*BasicNode {
	lines := strings.Split(s, "\n")
	nodes := make(map[string]*BasicNode)
	for _, line := range lines {
		var edgeName string
		if idx := strings.Index(line, ";"); idx >= 0 {
			edgeName = strings.Trim(line[idx+1:], " \t\r\n")
			line = line[:idx]
		}
		parts := strings.SplitN(line, "->", 2)
		if len(parts) != 2 {
			continue
		}
		head_name := strings.Trim(parts[0], " \t\r\n")
		tail_name := strings.Trim(parts[1], " \t\r\n")
		head := nodes[head_name]
		if head == nil {
			head = &BasicNode{Name: head_name}
			nodes[head_name] = head
		}
		tail := nodes[tail_name]
		if tail == nil {
			tail = &BasicNode{Name: tail_name}
			nodes[tail_name] = tail
		}
		edge := &BasicEdge{
			Name:     edgeName,
			EdgeHead: head,
			EdgeTail: tail,
		}
		head.AddEdge(edge)
	}
	return nodes
}
272370
func walkBinary(ctx expr.EvalContext, node *expr.BinaryNode, depth int) (value.Value, bool) {
	val, ok := evalBinary(ctx, node, depth)
	//u.Debugf("eval: %#v  ok?%v", val, ok)
	if !ok {
		return nil, ok
	}
	// if node.Negated() {
	// 	bv, isBool := val.(value.BoolValue)
	// 	if isBool {
	// 		return value.NewBoolValue(!bv.Val()), true
	// 	}
	// 	// This should not be possible
	// 	u.Warnf("Negated binary but non bool response? %T expr:%s", val, node)
	// }
	return val, ok
}
971218
func (n *NodeInfo) Taints() ([]v1.Taint, error) {
	if n == nil {
		return nil, nil
	}
	return n.taints, n.taintsErr
}
344327
func DFS(t Traversal, f Iter, u T) bool {
	lifo := NewLIFO(u)
	for lifo.Size() > 0 {
		next, _ := lifo.Pop()
		if t.Visited(next) {
			continue
		}
		if f(next) {
			return true
		}
		for _, v := range t.Edges(next) {
			lifo.Push(v)
		}
	}
	return false
}
341719
func (b *Bucket) forEachPageNode(fn func(*page, *node, int)) {
	// If we have an inline page or root node then just use that.
	if b.page != nil {
		fn(b.page, nil, 0)
		return
	}
	b._forEachPageNode(b.root, 0, fn)
}
32221
func (h *overlay) FS() ctxvfs.FileSystem {
	return ctxvfs.Sync(&h.mu, ctxvfs.Map(h.m))
}
293427
func (o *UplinkConnection) BFDSessions(info *bambou.FetchingInfo) (BFDSessionsList, *bambou.Error) {

	var list BFDSessionsList
	err := bambou.CurrentSession().FetchChildren(o, BFDSessionIdentity, &list, info)
	return list, err
}