I am being passed a series of keyvaluepair<string, uint>
pairs, where the string represents a value and the uint represents how frequently the value has occurred in the source data. I need to be able to hold in memory the x most/least frequently occurring values, along with it's frequency.
x in this case should be reasonably small but I am potentially having to examine several million pairs. Please note also that I am not able to change how I am passed the pairs.
What is the best way to go about this? I'm guessing that having two arrays might be the best bet and as each value is passed, depending on the value, insert it into the sorted array and drop the least/most frequent value out.