stricklypni 0 Newbie Poster

would the code below work for an hash table as in searching prior to inserting part... would it actually step through the table as in through the nodes then to whatever cells the nodes point to ... i have no other way of checking just yet .. coding still in progress

Hash_table::insert(int row, int col) const
{
	result = success;
	int probe_count, increment, probe;
	probe = hash(new_entry);
	probe_count = 0;
	increment = 1;
	//still gotta find out a way out to set null to represent any    //empty location in the linked list
	//without having to use a key class
	while(table[probe] != null&&table[probe] != new_entry&&probe_count < (hash_size + 1)/2)
	{
		probe_count++;
		probe = (probe + increment)% hash_size;
		increment += 2;
	}
	//still tryin to figure out how to do this with a linked list
	if(table[probe] == null) table[probe] = new_entry;
	else if (table[probe] == new_entry)result = duplicate_error;
	else result = overflow;
	return result;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.