Quantcast
Channel: The 3ds Max Blog
Viewing all articles
Browse latest Browse all 73

High Performance C# Collections

$
0
0

I am very interested in C# programming. It is currently my favorite language. One of my favorite parts is LINQ and IEnumerable. It allows me to express powerful algorithms easily and extremely succinctly.

For many of the alogirhtms we write for 3D modeling and animation the IEnumerable interface isn't the best abstraction we could be using. It is extremely general purpose and as a result the performance suffers in certain cases. The most noticeable issues are that random access of elements (IEnumerable.ElementAt()) and retrieving the number of items (IEnumerable.Count()) in an IEnumerable have a worst-case complexity of O(N). In other words, it is very slow, because the implementation requires iterating through all elements in the array.

As a side-project I have been researching how we can improve the performance of collections if we can start from a different set of assumptions. For example, what would happen if we could assume that the underlying collection was arranged sequentially in memory and was immutable, effectively a read-only array.

The first result of my research is a new article on CodeProject called Efficient Map Operations for Arrays in C# that compares the implementation of various implementations of a map higher-order function (also known as IEnumerable.Select() in the C# world).

If you are interested in high-performance C# code check it out!


Viewing all articles
Browse latest Browse all 73

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>