MCPcopy Create free account
hub / github.com/ZDoom/Raze / DelKey

Method DelKey

source/common/utility/tarray.h:1560–1597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1558 }
1559
1560 void DelKey(const KT key)
1561 {
1562 Node *mp = MainPosition(key), **mpp;
1563 HashTraits Traits;
1564
1565 if (mp->IsNil())
1566 {
1567 /* the key is definitely not present, because there is nothing at its main position */
1568 }
1569 else if (!Traits.Compare(mp->Pair.Key, key)) /* the key is in its main position */
1570 {
1571 if (mp->Next != NULL) /* move next node to its main position */
1572 {
1573 Node *n = mp->Next;
1574 mp->~Node(); /* deconstruct old node */
1575 CopyNode(mp, n); /* copy next node */
1576 n->SetNil(); /* next node is now nil */
1577 }
1578 else
1579 {
1580 mp->~Node();
1581 mp->SetNil(); /* there is no chain, so main position is nil */
1582 }
1583 --NumUsed;
1584 }
1585 else /* the key is either not present or not in its main position */
1586 {
1587 for (mpp = &mp->Next, mp = *mpp; mp != NULL && Traits.Compare(mp->Pair.Key, key); mpp = &mp->Next, mp = *mpp)
1588 { } /* look for the key */
1589 if (mp != NULL) /* found it */
1590 {
1591 *mpp = mp->Next; /* rechain so this node is skipped */
1592 mp->~Node();
1593 mp->SetNil(); /* because this node is now nil */
1594 --NumUsed;
1595 }
1596 }
1597 }
1598
1599 Node *FindKey(const KT key)
1600 {

Callers

nothing calls this directly

Calls 4

IsNilMethod · 0.80
~NodeMethod · 0.80
SetNilMethod · 0.80
CompareMethod · 0.45

Tested by

no test coverage detected