Reputation:
I am trying to use the SGI STL implementation I have downloaded from their site. I want to use a hashmap, because I have to store around 5.000.000 records, but it should be good: I need to be able to access it very quickly. I've tried stedext::hash_map
, but it was very slow because I couldn't set the initial size. By the way, is it possible to do that?
If I add the additional path to my MS Visual Studio, I can't even compile the example from the SGI site. I get an error message:
error C2061: syntax error : identifier 'T'.
Has anyone else faced such problems?
Upvotes: 0
Views: 10093
Reputation:
I confess I haven't tried it for myself, but VS2008 is supposed to support TR1 which contains:
#include <tr1/unordered_map>
it's in a "feature Pack" release. http://www.microsoft.com/downloads/details.aspx?FamilyId=D466226B-8DAB-445F-A7B4-448B326C48E7&displaylang=en
Upvotes: 2
Reputation: 7625
As was pointed out in a thread I noticed on a discussion forum about this issue the SGI STL implementation doesn't seem to have been updated in a very long time. On the download page it even mentions 8 Jun 2000 as the last time it was updated. I would suspect getting the SGI STL implementation to work under VS 2005/2008 is more trouble than its worth.
I would suggest checking out some STL alternatives...
Both are updated regularly.
Upvotes: 0
Reputation: 7625
Yes you will only find header files, that is indicated on the SGI STL website. As you noticed the link dependencies are for .lib files only so don't bother adding anything there.
You are compiling the example posted by Dan still right? You may need to specify your include headers using quotes rather than brackets. So use...
#include "hash_map"
instead of...
#include <hash_map>
It could be an issue with how include files are being searched for by the compiler. As an additional inquiry what version of Visual Studio are you using?
Upvotes: 0
Reputation:
I've dowloaded the zipped version of this library, there are only header files in that zip. There is another option under Linker, it is calles additional dependencies, but there are only *.lib files there. The command line of my settings looks:
/Od /I "C:\SGI" /D "_MBCS" Gm /EHsc /RTC1 /MDd /Fo"Debug\\"/Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt
I don't whether it is more usable....
Upvotes: 0
Reputation: 7625
That sounds reasonable. What is the structure of your STL directory? Did you get all the SGI STL files from their website or just a single one? It could be that you're missing a dependency file which is resulting in the error you are seeing.
Upvotes: 0
Reputation:
I have used it a number of times without problems, though I used it with gcc (both on windows and linux) and not Visual Studio.
For actual usage, the documentation is here.
You can specify how many buckets to reserve using
void resize(size_type n)
Regarding your issue with identifier T, I assume you have forgotten to replace a template argument, named T, with an actual type. If you can't figure it out, maybe paste a code snippet of how you are using the hash_map.
Example from the documentation:
#include <hash_map>
#include <iostream>
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
int main()
{
std::hash_map<const char*, int, hash<const char*>, eqstr> months;
months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;
std::cout << "september -> " << months["september"] << endl;
std::cout << "april -> " << months["april"] << endl;
std::cout << "june -> " << months["june"] << endl;
std::cout << "november -> " << months["november"] << endl;
}
Of course, you can use std::string instead of char* if you wish:
std::hash_map<std::string, int, hash<std::string>, eqstr> months;
Upvotes: 1
Reputation: 7625
Are there any other error messages showing up when you try to build/compile your project?
You mentioned you...
added an additional directory to a project where the SGI STL is.
Could you expand on that a bit? There are many places you can add directories in visual studio project settings. i.e. adding additional include header paths, additional library paths, etc. Where did you add your directory?
Upvotes: 0