Anybody notice that sometimes the node count is inaccurate? I noticed that sometimes a duplicate key manages to get past the duplicate key check, resulting in the node with the corresponding key taking on the new value. When this happens, the node count is incremented, however, no new node has been added.
(this is a cross post from "Red-Black Trees in C#")
I need to do a very simple task: go over 1 million numbers, and find the 6 biggest ones. in C++, I did this using a special implementation of a heap (that I did). it is a template heap of set size (lets say 6). then it has a special "insert" function that inserts an item to the heap, but removes the smallest item (pop()) if the heap is full.
as far as I can tell this is the most memory and CPU efficient way of doing this.
however, in .NET I can not find a good way for doing the same task (short of implementing my own heap again). I don't think this RB tree can help me,
bug if you guys think it can let me know. also, the TReap is not a good option (IMHP) because it has a very high overhead compared with a simple heap.
IDictionary seems a reasonable way to go, and the Dictionary implementation uses IComparable. Generally I'd use ICompare to do mixed comparisons, and IComparable<> to compare within a type.
Last Visit: 12-Jul-20 22:23 Last Update: 12-Jul-20 22:23