Skip to content

Instantly share code, notes, and snippets.

@psycharo-zz
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save psycharo-zz/f423aeaf71c0b1dcf4d3 to your computer and use it in GitHub Desktop.

Select an option

Save psycharo-zz/f423aeaf71c0b1dcf4d3 to your computer and use it in GitHub Desktop.
simple c++11ish heap
map<double, size_t> top;
size_t max_size = 100;
auto top_add = [&top,max_size](double value, size_t id)
{
if (top.size() < max_size)
top.insert(make_pair(value, id));
else
{
if (top.begin()->first < value)
{
top.erase(top.begin());
top.insert(make_pair(value,id));
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment