首页 > 其他 > 详细

OvS: data structure analysis

时间:2017-01-15 13:41:25      阅读:235      评论:0      收藏:0      [点我收藏+]

hmap usage:

in include/openvswitch/shash.h, we have:

技术分享

at first glance, it is a hmap encapsulated in shash.

In case we forget what is a hmap:

技术分享

技术分享

Obviously, it is the simplist hash map linked list. The mask means the max-hash value, the n means the total number of hashed members saved in hmap. Buckets[i] all have same hash value according to mask.

When we save key-value things, first put it in a shash_node, together with hmap_node inside it, push the hmap_node to the hmap hash linked list defined inside shash. When we search for search value of a key, gen key‘s hash and find in the hmap inside shash, get the hmap_node, CONTAINER_OF the hmap_node is the shash_node, then shash_node->name, shash_node->data is reachable.

OvS: data structure analysis

原文:http://www.cnblogs.com/sansna/p/6286951.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!