Why are hash tables absent from the STL?

J

jacob navia

Is there a reason, (a document indicating) why hash tables aren't a
standard container?

The same thing with single linked lists. They are a very popular way of
implementing lists (less overhead)

Thanks in advance
 
J

Jorgen Grahn

Is there a reason, (a document indicating) why hash tables aren't a
standard container?

There must have been /some/ discussions in the distant past which
ended up in e.g. this one not being included in C++ 98:

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

But obviously there were no fundamental reasons they couldn't be
included, since std::tr1::unordered_map now exists.
The same thing with single linked lists. They are a very popular way of
implementing lists (less overhead)

That would be std::forward_list -- new in C++0x. Or the traditional
<http://www.sgi.com/tech/stl/Slist.html> which, like hash_map, never got
standardized back in the 1990s.

/Jorgen
 
J

jacob navia

Le 29/06/11 14:21, Bo Persson a écrit :
There was. The proposal just came in too late to make it into the 1998
standard.

It was included in the TR1 update and will be present in C++11 (as
unordered_map).



Bo Persson
Interesting. That means that hash tables will be in C++ 2011.

What about single linked list? Are they also included?
 
G

Garrett Hartshaw

Is there a reason, (a document indicating) why hash tables aren't a
standard container?

The same thing with single linked lists. They are a very popular way of
implementing lists (less overhead)

Thanks in advance

Hash tables are in the next standard as std::unordered_set and
std::unordered_map. I think they are also in std::tr1 for current
use, but I'm not sure.
 
R

Rainer Grimm

Hello,
Hash tables are in the next standard as std::unordered_set and
std::unordered_map. I think they are also in std::tr1 for current use,
but I'm not sure.
you are right. But you have not to use the tr1 extension. You can do it
with an actual gcc (4.6) directly. Only using the -std=c++0x flag.

#include <iostream>
#include <map>
#include <unordered_map>

int main(){

std::cout << std::endl;

// using the C++0x unordered_map
std::unordered_map<std::string,int> um {
{"Dijkstra",1972},{"Scott",1976},{"Wilkes",1967},{"Hamming",1968} };
um["Ritchie"] = 1983;
for(auto p : um) std::cout << '{' << p.first << ',' << p.second << '}';

std::cout << std::endl;

std::cout << std::endl;
}

Greetings from Rottenburg,
Rainer

* Englisch - erkannt
* Afrikaans
* Albanisch
* Arabisch
* Weißrussisch
* Bulgarisch
* Katalanisch
* Chinesisch
* Chinesisch (Vereinfacht)
* Chinesisch (Traditionell)
* Kroatisch
* Tschechisch
* Dänisch
* Niederländisch
* Englisch
* Estnisch
* Filipino
* Finnisch
* Französisch
* Galizisch
* Deutsch
* Griechisch
* Hebräisch
* Haitianisch
* Hindi
* Ungarisch
* Isländisch
* Indonesisch
* Irisch
* Italienisch
* Japanisch
* Koreanisch
* Lettisch
* Litauisch
* Mazedonisch
* Malaysisch
* Maltesisch
* Norwegisch
* Persisch
* Polnisch
* Portugiesisch
* Iberisches Portugiesisch
* Rumänisch
* Russisch
* Serbisch
* Slowakisch
* Slowenisch
* Spanisch
* Suaheli
* Schwedisch
* Thailändisch
* Türkisch
* Ukrainisch
* Vietnamesisch
* Walisisch
* Jiddisch

* Afrikaans
* Albanisch
* Arabisch
* Weißrussisch
* Bulgarisch
* Katalanisch
* Chinesisch
* Chinesisch (Vereinfacht)
* Chinesisch (Traditionell)
* Kroatisch
* Tschechisch
* Dänisch
* Niederländisch
* Englisch
* Estnisch
* Filipino
* Finnisch
* Französisch
* Galizisch
* Deutsch
* Griechisch
* Hebräisch
* Haitianisch
* Hindi
* Ungarisch
* Isländisch
* Indonesisch
* Irisch
* Italienisch
* Japanisch
* Koreanisch
* Lettisch
* Litauisch
* Mazedonisch
* Malaysisch
* Maltesisch
* Norwegisch
* Persisch
* Polnisch
* Portugiesisch
* Iberisches Portugiesisch
* Rumänisch
* Russisch
* Serbisch
* Slowakisch
* Slowenisch
* Spanisch
* Suaheli
* Schwedisch
* Thailändisch
* Türkisch
* Ukrainisch
* Vietnamesisch
* Walisisch
* Jiddisch

<javascript:void(0);> <#>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top