作者a3785lexx (Alex)
看板EE_DSnP
标题[困惑] BddMgr::uniquify的写法...
时间Sun Jan 17 14:15:51 2010
其实我很不想要来骗P币的...
但是这个问题我怎麽想都觉得很怪...囧rz
故事沿续自昨天我发现我跑了几个电路,ref count都不对
最後跟强者我同学伸了uniquify换上去之後
就work了...
我原本的写法是
BddNodeInt* n = new BddNodeInt(l, r, i);
check the hash table
if found, update n
if not, add n into hash table
return n;
这样就挂了...
可是如果改成
BddNodeInt* n = 0;
check the hash table
if found, update n
if not,
n = new BddNodeInt(l, r, i);
add n into hash table
return n;
就可以了work了@@"
完全没有头绪,不是应该ref count 只会被BddNode控制吗囧?
怎麽先new和後new我的BddNodeInt结果会不一样呢@@?
好奇怪呀......我一定是有甚麽观念没有搞清楚了...orz
能够请教请教吗XD?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.37.88.214
1F:推 cmh317:你先new的话 nodeInt会呼叫node的constructor吧 所以 01/17 14:54
2F:→ cmh317:l,r的 ref count会被+1 所以要是你new出来没delete 01/17 14:55
3F:→ cmh317:l,r的ref count就会错吧@@ 01/17 14:55
4F:推 cmh317:在if found的情况下 01/17 14:57
5F:→ a3785lexx:欧懂了! 01/17 15:20
6F:→ a3785lexx:太感谢了!! 01/17 15:20