MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / Add

Method Add

ecgo/utils/map.go:50–67  ·  view source on GitHub ↗

adds (e, v) to the map, returns the current value when e already exists

(e Hashable, v interface{})

Source from the content-addressed store, hash-verified

48
49// adds (e, v) to the map, returns the current value when e already exists
50func (m Map) Add(e Hashable, v interface{}) interface{} {
51 h := e.HashCode()
52 s, ok := m[h]
53 if !ok {
54 s = make([]mapEntry, 0, 1)
55 } else {
56 for _, x := range s {
57 if x.e.EqualI(e) {
58 return x.v
59 }
60 }
61 }
62 m[h] = append(s, mapEntry{
63 e: e,
64 v: v,
65 })
66 return v
67}
68
69// filter (e, v) in the map using f(v), returns the keys
70func (m Map) FilterKeys(f func(interface{}) bool) []Hashable {

Callers 5

randomCircuitMethod · 0.45
randomEvalMethod · 0.45
applyCircuitFunction · 0.45
testRandomCircuitFunction · 0.45
evalSubMethod · 0.45

Calls 2

HashCodeMethod · 0.80
EqualIMethod · 0.80

Tested by 1

testRandomCircuitFunction · 0.36