Re: hash table with negative number
Quote:
Originally Posted by LarryChen
Can you use hash function without using any of STL?
Obviously :)
Quote:
Originally Posted by LarryChen
I repeat my original quesiton. There is an array, int a[] = {3, -1, 5, 7, -6}. How'd I build a hash table based on this array without using any of STL?
Why not start by taking MrViggy's suggestion of using an array of lists? There is no requirement to use any existing library in that suggestion. It makes sense to use an existing library where it is applicable (and it does not have to be the STL part of the C++ standard library: it could be a library component from whatever programming language that is in use), but if you insist otherwise, just implement what you need.
That is, if you want the functionality of a std::vector<std::list<foo> >, but you insist on not using these containers, then start by implementing your own version of std::vector and std::list.