Re: key / value lookup

From: Priyesh (PriyeshPadmavilasom_at_cougarmtn.com)
Date: 10/14/04


Date: Thu, 14 Oct 2004 07:18:57 -0700

Thanks for all your help. It helped me expand my options and have a better
understanding on the current data structures that i use.

"Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom> wrote in message
news:uJ10CJesEHA.3320@TK2MSFTNGP15.phx.gbl...
>
> "Priyesh" <PriyeshPadmavilasom@cougarmtn.com> wrote in message
> news:eXICgyVsEHA.2192@TK2MSFTNGP14.phx.gbl...
>> Thanks for your reply.
>>
>> The values are unique, with no correlation between keys and values. When
>> a
>> sorted vector is used, wouldnt the lookup times be higher compared to the
>> map version?
>
> No a sorted vector would be faster. map is usually implemented in terms of
> a
> balanced binary tree like Red-Black trees or AVL trees. vector also good
> locality of reference as the standard now guarantees it is a linear strip
> of
> memory (processor cache hits come into play) where as map does not (as
> each
> node could be allocated anywhere in memory, so searching has to trace
> pointers to nodes).
>
> Both are O(log N) to search but I expect a sorted vector to be faster.
>
> Where map wins out is when you have constantly insert or delete arbitrary
> keys. vector is O(N) then. If that does not apply, vector is a winner.
>
>> I suppose the map is using a hashtable
>
> Not normally. A unordered_map or hash_map or similar can have, with the
> right hashing function O(1) lookup.
>
>> so it is an array index
>> access to find the value. Could you please give your reasons otherwise?
>
> Since Dinkumware provides hash_map, map and vector, why don't you try each
> out an measure? Empirical tests are best.
>
> Stephen Howe
>
>
>
>
>



Relevant Pages

  • Re: key / value lookup
    ... with no correlation between keys and values. ... > map version? ... No a sorted vector would be faster. ... right hashing function Olookup. ...
    (microsoft.public.vc.stl)
  • Re: Cached ADO
    ... my caching layer is based on STL too. ... >> much faster indexed searching on a large emount of data. ... > _just_ to use a map. ... > thread-safe and of course bugs can creep in. ...
    (microsoft.public.data.ado)
  • WC3/AoE... NWTR/Michi
    ... Age of Empires Conquerors Michi and WarCraft III "No Where to Run, ... 2v2 and the Age of Empires map is up to 4v4. ... Both sides start separated by a row of trees. ...
    (comp.sys.ibm.pc.games.strategic)
  • Re: PC wont share files.
    ... Map the drive that I cannot see or access? ... Try Searching for the computer that will not share...Use the search ... file sharing and turned off the fire wall. ...
    (microsoft.public.windowsxp.general)
  • Re: Delorme SA2006 vs MS Streets and Trips 2006
    ... seconds to bring up the map at Eastman. ... The appropriate map came up at once, ... I did just remember that, a long time ago, Dan Lawyer said that Find would search layers. ... I'd like to see an option to turn off layer searching. ...
    (rec.outdoors.rv-travel)