MCPcopy Create free account
hub / github.com/adriancable/eternal / DelKey

Method DelKey

doom/src/tarray.h:935–972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

933 }
934
935 void DelKey(const KT key)
936 {
937 Node *mp = MainPosition(key), **mpp;
938 HashTraits Traits;
939
940 if (mp->IsNil())
941 {
942 /* the key is definitely not present, because there is nothing at its main position */
943 }
944 else if (!Traits.Compare(mp->Pair.Key, key)) /* the key is in its main position */
945 {
946 if (mp->Next != NULL) /* move next node to its main position */
947 {
948 Node *n = mp->Next;
949 mp->~Node(); /* deconstruct old node */
950 CopyNode(mp, n); /* copy next node */
951 n->SetNil(); /* next node is now nil */
952 }
953 else
954 {
955 mp->~Node();
956 mp->SetNil(); /* there is no chain, so main position is nil */
957 }
958 --NumUsed;
959 }
960 else /* the key is either not present or not in its main position */
961 {
962 for (mpp = &mp->Next, mp = *mpp; mp != NULL && Traits.Compare(mp->Pair.Key, key); mpp = &mp->Next, mp = *mpp)
963 { } /* look for the key */
964 if (mp != NULL) /* found it */
965 {
966 *mpp = mp->Next; /* rechain so this node is skipped */
967 mp->~Node();
968 mp->SetNil(); /* because this node is now nil */
969 --NumUsed;
970 }
971 }
972 }
973
974 Node *FindKey(const KT key)
975 {

Callers

nothing calls this directly

Calls 3

IsNilMethod · 0.80
SetNilMethod · 0.80
CompareMethod · 0.45

Tested by

no test coverage detected