Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Containers

Reply
Thread Tools

Containers

 
 
Carlos Martinez Garcia
Guest
Posts: n/a
 
      03-21-2006
I need to use a container for finding elements, but the key is composed.

I have read about map and hash_map, but I don't see the diferences.

hash_map uses a hash function, but I don't know it hash function is
important in terms of efficiency.

Which is the best container for that?

Thanks in advance
 
Reply With Quote
 
 
 
 
Mark P
Guest
Posts: n/a
 
      03-21-2006
Carlos Martinez Garcia wrote:
> I need to use a container for finding elements, but the key is composed.
>


What do you mean by "composed"?

> I have read about map and hash_map, but I don't see the diferences.
>


A hash_map uses a hash function to place and locate its elements, a map
uses a comparison function to keep its elements sorted and uses binary
search to place and locate them. Assuming you have a good enough hash
function, inserts, finds, and removals on a hash_map are O(1), whereas
they are O(log N) on a map. However if you need to iterate through the
elements in sorted order, then a map is your only option. Also,
hash_map is currently not standard and therefore not necessarily portable.

> hash_map uses a hash function, but I don't know it hash function is
> important in terms of efficiency.


Naturally, this depends. It can be.

>
> Which is the best container for that?


For what?

-Mark
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are sequence containers not a subset of general containers? Sebastian Mach C++ 5 10-06-2012 07:54 PM
Containers of iterators vs. containers of references clark.coleman@att.net C++ 7 01-25-2008 01:37 PM
CSS - horizontally aligned containers at same height hgwoss@gmx.de HTML 0 03-22-2006 11:03 AM
jsp, containers, beans and persistence milkyway Java 2 12-16-2004 01:46 PM
Highlighing Text in non-Focussed Containers Mike Westerfield Java 1 12-08-2003 10:55 AM



Advertisments