Saturday, 15 March 2014

c++ - hybrid linked list constructed on unordered_map? -


Hello, I wonder if I want to set up my own command between the key in the unmanned_map, Can I set the structure related to? Or is there a standard library? I need to look at the work of unmodified_map fast ...

For example:

  # include & lt; String & gt; # Include & lt; Tr1 / unordered_map & gt; Structure Linker {string * pt; String * hair 1; String * child 2; }; Unordered_map & lt; String, integer & gt; Map ({{"aaa", 1}, {"bbb", 2}, {"ccc", 3}, {"ddd", 4}}); Linker node 1 = new linker; Node1.pt = & amp; Map.find ("aaa") - & gt; first; Node1.child1 = & amp; Map.find ("ccc") - & gt; first; Node1.child2 = & amp; Map.find ("ddd") - & gt; first; One way to optimize hash lookup is to find a hash function that produces a small number. Hash collision on the keys you are using.  

With you can also rearrange the elements in the bucket, if you tilt it like this.

No comments:

Post a Comment