作者WSzc (WSzc)
看板EE_DSnP
標題[問題] testhash
時間Thu Jun 18 02:20:53 2009
想請問一下
在testHash.cpp中
hash insert順序是
hh.insert(10, 10.0);
hh.insert(20, 20.0);
hh.insert(10, 15.0);
hh.insert(2, 2.0);
hh.insert(5, 5.0);
hh.insert(16, 16.0);
在.out是
2 --> 2
16 --> 16
10 --> 10
5 --> 5
20 --> 20
請問為什麼不是10 --> 10,15 而是只有 10 --> 10?
hash不是會有collision讓它接在後面嗎?
另外想請問
就是cache中不像hash有一個bucketNum() function來決定要插入哪個cacheNode
所以是我們可以自訂插入規則嗎? 還是一樣用key % bucketNum去決定?
這樣的話output出來的順序就會跟testHash.out不同...
(像是.out這邊2被5蓋掉 如果規則不一樣 被蓋掉的node就不同了)
謝謝回答
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.161.46.220