c++ - Can't seem to break a while loop on collision, hashing -
i don't know why code not breaking out of while loop:
int table_size = 953; store hash_table[953]; for(int = 0; < table_size; i++) hash_table[i].count = 0; //bunch of stuff 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; // check value of count in array, 0, should have broken loop }
you mean:
while(hash_table[hashnum].data != pstring && hash_table[hashnum].count != 0)
in code loop continue if either case true, hash_table[hashnum].count == 0
not sufficient make clause false.
Comments
Post a Comment