MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / SPop

Method SPop

internal/data/set.go:95–106  ·  view source on GitHub ↗

SPop removes and returns one or more random elements from the set value store at key.

(key string)

Source from the content-addressed store, hash-verified

93
94// SPop removes and returns one or more random elements from the set value store at key.
95func (s *Set) SPop(key string) *core.Record {
96 if !s.SHasKey(key) {
97 return nil
98 }
99
100 for hash, record := range s.M[key] {
101 delete(s.M[key], hash)
102 return record
103 }
104
105 return nil
106}
107
108// SCard Returns the set cardinality (number of elements) of the set stored at key.
109func (s *Set) SCard(key string) int {

Callers 1

TestSet_SPopFunction · 0.95

Calls 2

SHasKeyMethod · 0.95
deleteFunction · 0.85

Tested by 1

TestSet_SPopFunction · 0.76