I am looking for a free implementation of limited priority abstraction software in C ++. Basically, I need a data structure that will behave exactly the same as std::priority_queue, but will always contain the "best" n elements.
Example:
std::vector<int> items;
bounded_priority_queue<int> smallest_items(5);
for(vector<int>::const_iterator it=items.begin(); it!=items.end(); it++) {
smallest_items.push(*it);
}
Does anyone know of a good implementation of such a thing? Any experience with him?
source
share