作者ric2k1 (Ric)
看板EE_DSnP
標題Re: [問題] 可以自己增加function嗎?
時間Tue Jan 12 21:23:09 2010
※ 引述《dryman (dryman)》之銘言:
: 好比說Hash table中沒有刪除HashNode的功能
: 如果在別的地方刪除東西卻沒有連帶將HashTable中的東西刪去
: 下次造出同樣的HashKey的時候就會在HashTable中檢查到有物件存在
: 然後就會gg...
: 現在我只想得到要從class Hash中加入function來解決這個問題
: 還是說有別的解決方法但我漏看了@ @"
That's why we have only ONE function "BddMgr::uniquify()" to allocate
BddNodeInt* and insert it into Hash (_uniqueTable).
Similarly, if you want to remove/delete a BddNodeInt*, you should have a
unified function (in BddMgr) to do it, instead of opening several backdoors
for it. In general, class Hash should be generic. It cannot assume whether
the stored data are of object types or pointers. So you should not have a
function in Hash to delete the Hash node.
However, in this project, you don't need to worry about deleting BddNodeInt*,
unless you are working on some bonus feature.
: 另外還想自己做一些priavate functions to imporve performance
: 不知道class Hash中可否自己加東西?
Sure, you can add something to Hash/Cache. Just be sure that we can compile
your code after the MustExist/MustRemove thing.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.224.47.210
1F:推 dryman:原來如此!寫一個unify delete helper function就行了! 01/12 21:43
2F:→ dryman:謝謝老師詳盡的解說~ 01/12 21:43