MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / add

Method add

structure/set.go:325–336  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
325func (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

Callers 2

SAddsMethod · 0.80
TestFSetsExistsFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestFSetsExistsFunction · 0.64