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)
| 1022 | // The RemoveNode's primary purpose is to provide a way to securely and |
| 1023 | // efficiently remove a node from the FZSet structure. |
| 1024 | func (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 | |
| 1039 | func (fzs *FZSet) exists(score int, member string) bool { |
| 1040 | v, ok := fzs.dict[member] |