Novaleaf Technical Diary
.Net SortedSet<T> is almost awesome

I’m working on rendering infrastructure right now, and came up with an idea for how to store and sort renderPackets based on criteria efficiently using a binary heap.

What’s the BCL got?

That’s great, but I remembered seeing an MSDN article on a new BCL collection called SortedSet<T>

Nice features

It’s pretty sweet.  As this CodeProject article describes, it has a neat Sub-Tree filter that can be used to partition the view, and it has good CPU performance with O(LogN) time.

Not good enough

Unfortunately, it seems like the BCL team is lapsing a bit on QC:  SortedSet<T> is implemented using classes for Nodes, not structs.  This has massive, harmfull, repercussions on CF.NET, and therefore makes SortedSet<T> unusable for a core, high-performance game system.

What’s to be done?

Thankfully, I can salvage the goodness of SortedSet’s features by implementing my own version of the class using a struct Node[] array as storage.  It’ll take a little time, but I can use the BCL API’s as reference, and that will give me a SortedSet that offers good CPU and GC performance.

-JasonS

blog comments powered by Disqus