해시 충돌에 while 루프를 깰 수없는 것 :내가이 코드는 while 루프에서 파괴되지 않는 이유를 모르는
int table_size = 953;
store hash_table[953];
for(int i = 0; i < table_size; i++)
hash_table[i].count = 0;
//bunch of stuff to get hash value here
while(hash_table[hashNum].data != pString || hash_table[hashNum].count != 0){
hashNum++;
if(hashNum > table_size)
hashNum = 0;
cout << hash_table[hashNum].count;
// to check the value of the count in the array, it IS 0, thus should have broken the loop
}
kingcong3 @, 이진 논리를 살펴해야 다음'&&'을 강조. 그 순간에, 당신의 코드는 "그 중 하나가 사실이라면 계속 진행"한다고 말합니다. 대신에,'&& '를 사용하면 "그 중 하나가 거짓이면 중지하십시오"를 의미합니다. – Smashery