473,804 Members | 3,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

replace std::map with <ext/hash_map>

g
hello!

I wanna replace an std::map<std::s tring,Services* >
with hash_map.How I will do this?

any link with examples?

transactions.in sert(std::pair< std::string,Ser vices*>("Aservi ce",new
xxxx));
transactions.in sert(std::pair< std::string,Ser vices*>("Vservi ce",new
fffff));
transactions.in sert(std::pair< std::string,Ser vices*>("Rservi ce",new
ttt));
...............

how I should replace this with hash_map?

thanks for any help.

Apr 20 '06 #1
10 7911
g wrote:
I wanna replace an std::map<std::s tring,Services* >
with hash_map.How I will do this?
What's "hash_map"? There is no such standard construct (yet, anyway).
any link with examples?
Have you tried Google?
transactions.in sert(std::pair< std::string,Ser vices*>("Aservi ce",new
xxxx));
transactions.in sert(std::pair< std::string,Ser vices*>("Vservi ce",new
fffff));
transactions.in sert(std::pair< std::string,Ser vices*>("Rservi ce",new
ttt));
...............

how I should replace this with hash_map?


It depends entirely what 'hash_map' exposes and what interface it has.
Do you think that knowing what "hash_map" is a prerequisite here? It's
not. Does it comply with the requirements for an associative container?
If it does, you probably need to use 'hash_map::valu e_type' instead of
'std::pair'. Maybe it's the same thing. Maybe not. Have you actually
tried compiling to see if it fails? If yes, where does it fail and with
what error message? If not, why not?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 20 '06 #2
In article <e2**********@n ews.datemas.de> ,
"Victor Bazarov" <v.********@com Acast.net> wrote:
g wrote:
I wanna replace an std::map<std::s tring,Services* >
with hash_map.How I will do this?


What's "hash_map"? There is no such standard construct (yet, anyway).


Fwiw, when (not if) it becomes standard, the likely name is
std::unordered_ map.

-Howard
Apr 20 '06 #3
g
hi !
I am googling but I haven't found something......

I wanna use the gnu/sgi extension

this code doesn't compile,it's from my std::map
transactions.in sert(std::pair< std::string,Ser vices*>("Aservi ce",new
xxxx));

I want to convert it to hash_map.....

hash_map<std::s tring,Services* ,hash<std::stri ng>> transactions;

this is the correct declaration?

Apr 20 '06 #4
In article <11************ **********@t31g 2000cwb.googleg roups.com>,
"g" <ge*******@yaho o.com> wrote:
hash_map<std::s tring,Services* ,hash<std::stri ng>> transactions;


Try:

hash_map<std::s tring,Services* ,hash<std::stri ng> > transactions;
^
space

Fwiw, that will be fixed in C++0X too... :-)

-Howard
Apr 20 '06 #5
On Thu, 20 Apr 2006 21:01:31 GMT Howard Hinnant
<ho************ @gmail.com> waved a wand and this message magically
appeared:
hash_map<std::s tring,Services* ,hash<std::stri ng> > transactions;
^
space

Fwiw, that will be fixed in C++0X too... :-)


What will it look like in C++0X? I do find that '<some type<different
type> >' syntax a bit ugly.

--
http://www.munted.org.uk

Take a nap, it saves lives.
Apr 20 '06 #6
In article <20************ *************** *****@munted.or g.uk>,
Alex Buell <al********@mun ted.org.uk> wrote:
On Thu, 20 Apr 2006 21:01:31 GMT Howard Hinnant
<ho************ @gmail.com> waved a wand and this message magically
appeared:
hash_map<std::s tring,Services* ,hash<std::stri ng> > transactions;
^
space

Fwiw, that will be fixed in C++0X too... :-)


What will it look like in C++0X? I do find that '<some type<different
type> >' syntax a bit ugly.


Sorry for the abbreviated message. My impression is that:

some_template<s ome_other_templ ate<some_type> > my_object;

will be equivalent to:

some_template<s ome_other_templ ate<some_type>> my_object;

But that's just my personal (and rushed) interpretation.

My latest factual information is that:

http://www.open-std.org/jtc1/sc22/wg...005/n1757.html

has been adopted into the C++0X working draft (which should be publicly
available in a few more days).

-Howard
Apr 21 '06 #7
g
thanks for your comments.

I still have a problem:

_gnu_cxx::hash_ map<std::string ,Services*, __gnu_cxx::hash <std::string>
transactions


transactions["CreateUser "]=new CreateUser;

the compiler give me this :

error: expected unqualified-id before '[' token

how to deal with?

thanks

Apr 21 '06 #8
g wrote:
thanks for your comments.

I still have a problem:

_gnu_cxx::hash_ map<std::string ,Services*, __gnu_cxx::hash <std::string>
transactions

Does your code include a ';' here? or was this a typo?

transactions["CreateUser "]=new CreateUser;

the compiler give me this :

error: expected unqualified-id before '[' token

how to deal with?

See above. Also I assume you have the appropriate includes.

Jeff Flinn
Apr 21 '06 #9
g
>Does your code include a ';' here? or was this a typo?

yes it does include ;.

I use <ext/hash_map>

Apr 21 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4858
by: Vasileios | last post by:
Hello could someone help me please. I have the following class definition #include <ext/hash_set> #include "tool.h" class ToolContainer : public QObject {
822
29859
by: Turamnvia Suouriviaskimatta | last post by:
I 'm following various posting in "comp.lang.ada, comp.lang.c++ , comp.realtime, comp.software-eng" groups regarding selection of a programming language of C, C++ or Ada for safety critical real-time applications. The majority of expert/people recommend Ada for safety critical real-time applications. I've many years of experience in C/C++ (and Delphi) but no Ada knowledge. May I ask if it is too difficult to move from C/C++ to Ada?...
4
8032
by: futureofphp | last post by:
I need to access a website, Fetch the data, and then logout. Please tell me where I am wrong. I dont think its logging out properly. <? include "Snoopy.class.php"; $snoopy = new Snoopy; //Logging in $submit_url =
4
2752
by: chrisstankevitz | last post by:
This code does not compile on gcc 3.4.4. Should it? Thanks for your help, Chris //================ #include <set> int main()
3
2945
by: newbie | last post by:
Same thing g++ complains when using hash_map<>, but is happy with map<--I understand hahs_map is not standardized, but since the compiler didn't complain something like 'hash_map<not defined', I suppose it's supported and should behave well when I used it correctly. BUT it didn't. Here is my code snippet: class MyKey { public: virtual void foo() { return; }
7
2117
by: creative1 | last post by:
I am trying form valdiation with javascript but it never call the function. can someone please test this code and see why it is like that. It screwed up my mind. here is my code: <!-- Java Script form form validation and entries --> <script language="JavaScript"> function checkForm() { alert("I am called"); var cfirstname, cemail, cpass, clastname; with(window.document.msgform)
2
5147
by: jeddiki | last post by:
Hello, I want to create my own index of websites based on my criteria rather than big G's. For example, I might like to index websites according to what they have in their "author" Meta tag ( and rejecting any site that doesn't have one). I will use this idea as a working example. Here is my suggested methodology and I would like some input on problem areas, how to make it better, etc.
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.