myahya
myahya

Reputation: 3171

C++ hash table implementation with collision handling

What is a good C++ library for hash tables / hash maps similar to what java offers. I have worked with Google Sparsehash, but it has no support for collisions.

Upvotes: 2

Views: 2050

Answers (3)

user319799
user319799

Reputation:

In addition to those mentioned in other answers, you could try MCT's closed_hash_map or linked_hash_map. It is internally similar to Google SparseHash, but doesn't restrict values used and has some other functional advantages.

I'm not sure I understand what you mean by "no support for collisions", though. Both Google SparseHash and similarly implemented MCT of course handle collisions fine, though differently than Java's HashMap.

Upvotes: 1

anon
anon

Reputation:

Use std::unordered_map (or unordered_multimap), which despite its name is a hash table - it will be part of the next C++ standard, and is available in most current C++ implementations. Do not use the classes with hash in their names that your implementation may provide - they are not and will not be standard.

Upvotes: 6

Andreas Brinck
Andreas Brinck

Reputation: 52519

http://www.sgi.com/tech/stl/hash_multimap.html

or

std::tr1::unordered_multimap

Upvotes: 2

Related Questions