में "बाध्य प्राथमिकता कतार" का नि: शुल्क कार्यान्वयन मैं सीमाबद्ध प्राथमिकता कतार सी ++ में अमूर्तता का एक मुफ्त सॉफ़्टवेयर कार्यान्वयन की तलाश में हूं। असल में, मुझे एक डेटा संरचना की आवश्यकता है जो std::priority_queue
की तरह व्यवहार करेगी, लेकिन हर समय "सर्वश्रेष्ठ" n तत्वों को हमेशा "सर्वोत्तम" बनाएगा।सी ++
उदाहरण:
std::vector<int> items; // many many input items
bounded_priority_queue<int> smallest_items(5);
for(vector<int>::const_iterator it=items.begin(); it!=items.end(); it++) {
smallest_items.push(*it);
}
// now smallest_items holds the 5 smallest integers from the input vector
किसी को भी इस तरह के बात का एक अच्छा कार्यान्वयन की पता है? इसके साथ कोई अनुभव?
मुझे लगता है कि यह http://stackoverflow.com/questions/2933758/priority-queue-with-limited-space-looking-for-a-good-algorithm –
में शामिल है, खरीदारी के सवाल कभी नहीं चूसते हैं। –