FuncMatch - returns new set containing each value that passes match function. A 'matchFn' should accept element in a set as first argument and 'matchValue' as second argument. The function can do any logic to compare both the arguments and should return true to accept element in a set to include in
(matchFn func(T, T) bool, matchValue T)
| 90 | // compare both the arguments and should return true to accept element in |
| 91 | // a set to include in output set else the element is ignored. |
| 92 | func (set Set[T]) FuncMatch(matchFn func(T, T) bool, matchValue T) Set[T] { |
| 93 | nset := New[T]() |
| 94 | for k := range set { |
| 95 | if matchFn(k, matchValue) { |
| 96 | nset.Add(k) |
| 97 | } |
| 98 | } |
| 99 | return nset |
| 100 | } |
| 101 | |
| 102 | // ApplyFunc - returns new set containing each value processed by 'applyFn'. |
| 103 | // A 'applyFn' should accept element in a set as an argument and return |