现在的位置: 首页 > 综合 > 正文

Google Sparse Hash

2013年12月08日 ⁄ 综合 ⁄ 共 1153字 ⁄ 字号 评论关闭

http://goog-sparsehash.sourceforge.net/

 

An extremely memory-efficient hash_map implementation, with only 2 bits/entry overhead.


We've Moved!

Google SparseHash is now hosted at code.google.com. Our new homepage is located at http://code.google.com/p/google-sparsehash.

Overview

The Google SparseHash project contains several hash-map implementations in use at Google, with different performance characteristics, including an implementation that optimizes for space and one that optimizes for speed.

SparseHash is a template library; there are no binaries to install.

SparseHash is distributed under the terms of the BSD License.

For downloads, news, and other information, visit our Project Page

Example

This is by no means a complete example; it simply gives you a feel for what the Sparsehash API looks like.

#include <iostream><br /> #include <google></p> <p> struct eqstr<br /> {<br /> bool operator()(const char* s1, const char* s2) const<br /> {<br /> return (s1 == s2) || (s1 &amp;&amp; s2 &amp;&amp; strcmp(s1, s2) == 0);<br /> }<br /> };</p> <p> int main()<br /> {<br /> google::sparse_hash_map<const char int hash>, eqstr&gt; months;</p> <p> months.set_deleted_key(NULL);<br /> months["january"] = 31;<br /> months["february"] = 28;<br /> months["march"] = 31;<br /> months["april"] = 30;<br /> months["may"] = 31;<br /> months["june"] = 30;<br /> months["july"] = 31;<br /> months["august"] = 31;<br /> months["september"] = 30;<br /> months["october"] = 31;<br /> months["november"] = 30;<br /> months["december"] = 31;</p> <p> std::cout " " " " </const></google></iostream>

抱歉!评论已关闭.