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

Method RemoveNode

structure/zset.go:1024–1037  ·  view source on GitHub ↗

RemoveNode is a method for FZSet structure. This method aims to delete a node from both the dictionary (dict) and the skip list (skipList). The method receives one parameter: - member: a string that represents the key of the node to be removed from the FZSet structure. The method follows these ste

(member string)

Source from the content-addressed store, hash-verified

1022// The RemoveNode's primary purpose is to provide a way to securely and
1023// efficiently remove a node from the FZSet structure.
1024func (fzs *FZSet) RemoveNode(member string) error {
1025 // Check for existence of key in dictionary
1026 v, ok := fzs.dict[member]
1027 if !ok || fzs.dict == nil {
1028 return _const.ErrKeyNotFound
1029 }
1030
1031 // Delete Node from the skip list and dictionary
1032 fzs.skipList.delete(v.score, member)
1033 delete(fzs.dict, member)
1034 fzs.size--
1035
1036 return nil
1037}
1038
1039func (fzs *FZSet) exists(score int, member string) bool {
1040 v, ok := fzs.dict[member]

Callers 3

TestSkipList_deleteFunction · 0.80
ZRemMethod · 0.80
ZRemsMethod · 0.80

Calls 1

deleteMethod · 0.80

Tested by 1

TestSkipList_deleteFunction · 0.64