MCPcopy
hub / github.com/gofiber/fiber / Contains

Method Contains

extractors/extractors.go:81–109  ·  view source on GitHub ↗

Contains reports whether this extractor, or any extractor in its chain, matches pred. If pred is nil, Contains returns false.

(pred func(Extractor) bool)

Source from the content-addressed store, hash-verified

79//
80// If pred is nil, Contains returns false.
81func (e Extractor) Contains(pred func(Extractor) bool) bool {
82 if pred == nil {
83 return false
84 }
85
86 stack := make([]*Extractor, 0, len(e.Chain)+1)
87 stack = append(stack, &e)
88 visited := make(map[*Extractor]struct{}, len(e.Chain)+1)
89
90 for len(stack) > 0 {
91 last := len(stack) - 1
92 curr := stack[last]
93 stack = stack[:last]
94 if _, ok := visited[curr]; ok {
95 continue
96 }
97 visited[curr] = struct{}{}
98
99 if pred(*curr) {
100 return true
101 }
102
103 for i := range curr.Chain {
104 stack = append(stack, &curr.Chain[i])
105 }
106 }
107
108 return false
109}
110
111type chainGuardKey struct {
112 id *byte

Calls

no outgoing calls