By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,370 Members | 1,534 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,370 IT Pros & Developers. It's quick & easy.

Implement Map in C++

P: n/a
Hi all,

I wonder what are the possible ways to implement a Map
in C++?
Among these methods, which is the best one and why?

Thank you very much in advance.
Sean
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
sounds like a homework question....
Use the STL's map:

#include <map>

It's the best because it's
a) written for you
b) debugged
c) standard
d) interoperates with other stl features
cheerio.

Sean wrote:
Hi all,

I wonder what are the possible ways to implement a Map
in C++?
Among these methods, which is the best one and why?

Thank you very much in advance.
Sean

Nov 17 '05 #2

P: n/a
Hi,

Thanks for your reply.
It's not a homework question actually... but it's a
question that my friend asked me and I couldn't answer :)

I'm curious.
And I want to know how we can implement a Map in C++
without using the STL library. :)

I appreciate any ideas :)

Sean
-----Original Message-----
sounds like a homework question....
Use the STL's map:

#include <map>

It's the best because it's
a) written for you
b) debugged
c) standard
d) interoperates with other stl features
cheerio.

Sean wrote:
Hi all,

I wonder what are the possible ways to implement a Map
in C++?
Among these methods, which is the best one and why?

Thank you very much in advance.
Sean

.

Nov 17 '05 #3

P: n/a
Sean wrote:
Hi,

Thanks for your reply.
It's not a homework question actually... but it's a
question that my friend asked me and I couldn't answer :)

I'm curious.
And I want to know how we can implement a Map in C++
without using the STL library. :)


1. Use a Red-Black Tree (this is what most STL implementations use for
std::map)
2. Use a hash table (most STL implementations supply some form of hash_map)
3. Use an AVL tree.
4. Use a B Tree, B+ Tree or B* Tree.
5. Use a sorted vector of std::pair (this is actually more efficient in some
cases)
....

-cd
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.