internal/private functions add adds new elements to the set data structure (FSets). It allows one or more string parameters. If an element already exists, it won't be added again.
(member ...string)
| 323 | // add adds new elements to the set data structure (FSets). |
| 324 | // It allows one or more string parameters. If an element already exists, it won't be added again. |
| 325 | func (s *FSets) add(member ...string) { |
| 326 | |
| 327 | for _, m := range member { |
| 328 | // Check if the member to be added already exists in the FSets or not. |
| 329 | // existence of the element in the FSets needs to be checked, not the value. |
| 330 | if _, exists := (*s)[m]; !exists { |
| 331 | // If the elements do not already exist, add it to the set. |
| 332 | // The value here is an empty struct, because we are only interested in the keys. |
| 333 | (*s)[m] = struct{}{} |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | // remove is a method on the FSet struct that takes in a variable number |
| 339 | // of string parameters. It takes these strings to be "members", and generates errors |
no outgoing calls