MCPcopy Create free account
hub / github.com/Singular/Singular / remove

Method remove

kernel/oswrapper/vspace.h:906–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904
905template <typename Spec>
906bool VMap<Spec>::remove(VRef<K> key, VRef<K> &oldkey, VRef<V> &oldvalue) {
907 size_t hash = Spec::hash(key.as_ptr());
908 size_t b = hash & (_nbuckets - 1);
909 _lock_bucket(b);
910 VRef<Node> node = _buckets[b];
911 VRef<Node> last = vnull<Node>();
912 while (!node.is_null()) {
913 Node *node_ptr = node.as_ptr();
914 if (hash == node_ptr->hash
915 && Spec::equal(key.as_ptr(), node_ptr->key.as_ptr())) {
916 oldkey = node_ptr->key;
917 oldvalue = node_ptr->value;
918 // remove from list
919 if (last.is_null()) {
920 _buckets[b] = node_ptr->next;
921 } else {
922 last->next = node_ptr->next;
923 }
924 _unlock_bucket(b);
925 return true;
926 }
927 last = node;
928 node = node->next;
929 }
930 _unlock_bucket(b);
931 return false;
932}
933
934template <typename Spec>
935bool VMap<Spec>::find(VRef<K> key, VRef<V> &value) {

Callers

nothing calls this directly

Calls 2

as_ptrMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected