Browse by Tags

All Tags » CLR Internals » Algorithms (RSS)

Array.Resize is a pretty cool little tool. Copy hints might be a nice addition?

If you normally use the supporting collections, this won't be much of a toy for you. If you rely on arrays, and lots of them, and find yourself resizing them every now and then with little helper functions or inline resize code, then you should check...
Posted by Justin Rogers | with no comments

Performance: Refactoring generic List.RemoveAll... Speed lost in implementation and Array.Clear...

Well, I got railed after my previous posting on the List.RemoveAll method How is that RemoveAll method on the generic List actually implemented? . Apparently I'm not allowed to make basic comments anymore, and I quote "Now your remark is just information...

How does List<T>(IEnumerable<T>) avoid the costs of expanding the internal collection?

The interface IEnumerable<T> is just like the old interface IEnumerable. It allows a single method GetEnumerator which returns an IEnumerator<T>. This second interface has the property Current and a method for moving the index MoveNext . As...

We tend to use MOD parity everywhere. Alternating list styles, working with collections...

Just a short. Mathematically speaking, one of the definitions of parity is to determine oddness. A parity of 1 means that a given number is odd, while a parity of 0 means that number is even. This works out for us in alternating lists because what we...

How is that RemoveAll method on the generic List actually implemented?

We get lots of removal methods for the List<T> in Whidbey. You can Remove(T), or the first instance of some object or value. You an RemoveAt(int) and take something out of a given offset. You can even RemoveRange(int, int) and take out a whole group...

Performance: Whidbey generic Queue didn't get hit with the same performance stick as the generic Stack

I think I've narrowed down the new Whidbey generic Stack class to using a linked array Performance: Linked Arrays's now and later . I figured, hey, they must have used the same features in the Queue right? Not quite, in fact the generic queue can actually...

Performance: Linked Arrays's now and later

I love testing my code against the latest and greatest available in Whidbey. Turns out there are some collections that are insane when it comes to performance. One such collection is the generic Stack and of course the new Queue. Now both of these new...

Performance: Focusing on BinarySearch

If you take a look through Rotor you'll find a number of methods that have the signature TrySZ[...]. What these methods are meant to do is take intrinsic data types (int, float, long, etc...) and perform faster than normal operations on them. That is...

Performance: A quick-fix for the Pow functions. Acceptable approximations for a magnitude of speed.

I often use very small powers in approximating math functions used in gaming. Normally these are for AI activations where I'm computing a term that will be used in another expression, most likely a division, and all of my precision lies in the balance...

Performance: If you can avoid Math.Max, then maybe it is for the best? (integer testing)

I realized there were quite a few APIs inside of the BCL that were using Math.Max and figured that couldn't be good, not good at all. Math.Max has more meaning when you are talking about floating point values, because of IsNaN checks. After all, if it...
More Posts Next page »