Re: CMap and struct

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Arman Sahakyan wrote:

As others have noted you have some problems with the signatures of operator =() and operator ==().

As to HashKey(), you probably don't really need a hashed map, in which case you could use std::map from the standard library (std::map is a tree-based map, not a hash map).

In addition:
In this case he needs to overload operator < because std::map uses < to sort (insert into its search tree) elements of the container.

Ah, yes. I forgot about that. But no big deal. Easier than writing a hash function.

--
David Wilkinson
Visual C++ MVP
.



Relevant Pages

  • Re: Is STL::map Find operation the optimised ?
    ... If your map contains keys that are long and highly differentiated by ... can actually end up being faster than a hash map, ... characters, millions of records), I would not expect hash_map to be slower. ... both of them with your real data. ...
    (microsoft.public.vc.stl)
  • Re: Design of string storage
    ... And what I found was an implementation of a hash map. ... Then I would define some copy, allocation and free methods for this ... If I destroy my object I would decrease the ref count and maybe remove the ... a more or less comfortable/customizable hash map. ...
    (comp.programming)
  • Data structure recommendation?
    ... hash map. ... I want to map a RANGE of floats to an object. ... getshould return the object with the "newest" timestamp ...
    (comp.lang.python)
  • Re: Weak/Soft references?
    ... map, which you keep as ... indefinitely even if there is no other references to a list element. ... hinder collection. ... stops using the object, it will be removed from the hash map as well, so ...
    (comp.lang.java.programmer)
  • Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... current C++ standard only has ordered maps. ... Yes, but the analog to the C++ map is Ada.Containers.Ordered_Maps, not ... needs a relational operator (for the ordered map), ... function (for the hashed map). ...
    (comp.lang.cpp)