tag:blogger.com,1999:blog-2715968472735546962.post7013428771234892964..comments2023-12-14T02:21:18.222+01:00Comments on Bannalia: trivial notes on themes diverse: Implementation of C++ unordered associative containersJoaquín M López Muñozhttp://www.blogger.com/profile/08579853272674211100noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2715968472735546962.post-67245104701179551912015-12-29T14:44:56.149+01:002015-12-29T14:44:56.149+01:00okay thanks a lot. Much clearer.okay thanks a lot. Much clearer.Anonymoushttps://www.blogger.com/profile/12672091238688013003noreply@blogger.comtag:blogger.com,1999:blog-2715968472735546962.post-34314202378690322272015-12-29T10:36:18.335+01:002015-12-29T10:36:18.335+01:00In the case um.erase("AAB") the hash fun...In the case um.erase("AAB") the hash function will be invoked regardless of whether nodes store hash values or not. It is the following case when such stored value matters:<br /><br />auto it=um.find(...);<br />um.erase(it); // guaranteed by the standard not to throw<br /><br />When erasing through an iterator, the standard requires that erase not throw, which precludes using the hash function (as it might throw). As the hash value is absolutely needed (in libc++ and Boost.Unordered) to get the bucket in which the element pointed to by it belongs, a non-throwing solution is having the node store the value for readymade consumption.Joaquín M López Muñozhttps://www.blogger.com/profile/08579853272674211100noreply@blogger.comtag:blogger.com,1999:blog-2715968472735546962.post-36330153542529150682015-12-29T03:45:34.610+01:002015-12-29T03:45:34.610+01:00Hi,
Thanks for the wonderful explanation. I am re...Hi,<br /><br />Thanks for the wonderful explanation. I am really confused about one aspect. If In the boost.unordered or libc++ implementation I want to delete an entry by key, I don't understand how storing a hash value in the linked list node helps? I understand it links the data to the bucket. <br /><br />Can you explain a little more this line "we must connect an element with its bucket entry without invoking the hash function".<br /><br />Let us say I have a unordered_map and I have stored a key say "AAB" and the associated hash value is stored along with the key and value. IF I say <br /><br /><br /> boost::unordered_map um;<br />um["AAB"] = 1;<br />um.erase("AAB")<br /><br />In this case how does storing the "hash value" associated with "AAB" help me delete that entry without using the hash function? <br /><br />I am sorry maybe it is something I am missing but I don't understand.Could you please elaborate a little.Anonymoushttps://www.blogger.com/profile/12672091238688013003noreply@blogger.comtag:blogger.com,1999:blog-2715968472735546962.post-61216691208789324602014-09-28T04:41:09.636+02:002014-09-28T04:41:09.636+02:00Thank you for your impressing post, it's very ...Thank you for your impressing post, it's very helpful!蓝田日暖https://www.blogger.com/profile/09634083812646437565noreply@blogger.com