understack
understack

Reputation: 11580

Why C++ STL does not provide hashtable and union data structures?

At various places, I've read that STL does not provide hashtable and union data structures. How could these be implemented using other existing STL data structures?

Upvotes: 2

Views: 1383

Answers (2)

NG.
NG.

Reputation: 22904

Try the std::tr1::unordered_map for your hash map. std::map is ordered, so it's not really as efficient as hash. Not sure what you mean by a union data structure, but you can have unioned structs in C++

EDIT: Additionally there are many other implementations of hash maps that some have done. Boost has an unordered map, Prasoon mentioned one in the question comments, and Google has sparsehash.

Upvotes: 8

Protostome
Protostome

Reputation: 6019

Try std::map for your hash table needs...

Upvotes: 1

Related Questions