set
and vector
std::set
that represents our set of uncompressed values, we can
quickly compress it with a std::vector
and lower_bound
without having to
create an std::map
that holds the index!
set<int> ss; // input set to compress
vector<int> index(ss.begin(), ss.end());
int uncompressed = ...; //
int compressed = int(lower_bound(index.begin(), index.end(), key) - index.begin());
assert(xs[compressed] == uncompressed);