作者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