Skip to content

Instantly share code, notes, and snippets.

@yangacer
Created October 21, 2011 12:26
Show Gist options
  • Save yangacer/1303695 to your computer and use it in GitHub Desktop.
Save yangacer/1303695 to your computer and use it in GitHub Desktop.
hash_map shapshot
int main()
{
using namespace std;
using namespace BDB;
using BDB::Structure::HashMap;
Config conf;
conf.beg = 1;
conf.end = 10;
conf.root_dir = argv[1];
BehaviorDB bdb(conf);
HashMap<int> hmap("my_map", bdb);
string buf;
hmap.put("key", "value");
hmap.is_in("key");
hmap.get("key", &buf);
hmap.get_bucket("key");
size_t hv = hmap.hash_function("key");
HashMap<int>::BucketType bucket;
hmap.get_bucket(hv, &bucket);
for(HashMap<int>::BucketType::iterator it = bucket.begin();
it != bucket.end(); ++it)
cout<<it->first<<":"<<it->second<<"\n";
bucket.erase(bucket.begin());
hmap.update_bucket("key", bucket);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment