SUnion returns the members of the set resulting from the union of all the given sets.
(key1, key2 string)
| 240 | |
| 241 | // SUnion returns the members of the set resulting from the union of all the given sets. |
| 242 | func (s *Set) SUnion(key1, key2 string) ([]*core.Record, error) { |
| 243 | if !s.SHasKey(key1) || !s.SHasKey(key2) { |
| 244 | return nil, ErrSetNotExist |
| 245 | } |
| 246 | |
| 247 | records, err := s.SMembers(key1) |
| 248 | |
| 249 | if err != nil { |
| 250 | return nil, err |
| 251 | } |
| 252 | |
| 253 | for hash, record := range s.M[key2] { |
| 254 | if _, ok := s.M[key1][hash]; !ok { |
| 255 | records = append(records, record) |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | return records, nil |
| 260 | } |