Hello all,

I have created an array of linked lists called hash_array[]. I am trying to write a search function. I am getting compiler errors on line 7 & 9. They are below.

Line 7
warning C4018: '<' : signed/unsigned mismatch

Line 9
error C2784: 'bool std::operator ==(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'int'


I understand there is a problem comparing the two types. I have looked for a std::list function that retrieves the element, does one exist?

Also, is there a function that increments the iterator?

bool HashTable::search(int index, int k)
{
	bool value = 0;
	hash_array[index].begin();
	
	
	for(int i = 0; i < hash_array[index].size(); i++)
	{
		if(k == hash_array[index])
		{
			bool = 1;
		}
		
		else
		{
			hash_array[index]++;
		}
	
	}

	return value;

}
for(int i = 0; i < hash_array[index].size(); i++)

//Should be:

for(unsigned short i = 0; i < hash_array[index].size(); i++)

Also you cannot compare an int to an iterator.. .begin() and .end() are both iterators..

you can actually do something like: for(it.begin(); it.end(); it++)

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.