MCPcopy Create free account
hub / github.com/ardanlabs/gotraining / Operate

Method Operate

topics/go/algorithms/data/stack/stack.go:70–77  ·  view source on GitHub ↗

Operate accepts a function that takes data and calls the specified function for every piece of data found. It traverses from the top down through the stack.

(f func(data *Data) error)

Source from the content-addressed store, hash-verified

68// the specified function for every piece of data found.
69// It traverses from the top down through the stack.
70func (s *Stack) Operate(f func(data *Data) error) error {
71 for i := len(s.data) - 1; i > -1; i-- {
72 if err := f(s.data[i]); err != nil {
73 return err
74 }
75 }
76 return nil
77}

Callers 1

TestPushFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestPushFunction · 0.76