Skip to content

Instantly share code, notes, and snippets.

@xquery
Created October 3, 2017 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xquery/50dc6fb1c06193da69928d7b996480b8 to your computer and use it in GitHub Desktop.
Save xquery/50dc6fb1c06193da69928d7b996480b8 to your computer and use it in GitHub Desktop.
ptable impl with mmap
#include <iostream>
#include <map>
using namespace std;
typedef multimap <string, tuple<int,int> > ptable;
int main() {
string orig = "a large span of text";
string add = "english";
ptable pt;
pt.insert(make_pair("orig",make_tuple(0,2)));
pt.insert(make_pair("orig",make_tuple(8,8)));
pt.insert(make_pair("add",make_tuple(0,8)));
pt.insert(make_pair("orig",make_tuple(16,4)));
for (ptable::iterator it = pt.begin(); it != pt.end(); ++it)
{
cout << it->first << "=(" << get<0>(it->second) << "," << get<1>(it->second) << ")" << endl;
}
cout<< pt.size() << endl;
return 0;
}
@xquery
Copy link
Author

xquery commented Oct 3, 2017

emits

add=(0,8)
orig=(0,2)
orig=(8,8)
orig=(16,4)
4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment