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)
| 68 | // the specified function for every piece of data found. |
| 69 | // It traverses from the top down through the stack. |
| 70 | func (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 | } |