Browse by Tags

All Tags » CLR Internals » Quick Tips » Algorithms (RSS)

Article on file line counting algorithms. Covering fast exact counting and statistical counting.

Someone asked a question on the C# newsgroup yesterday and a large number of answers have been flying around. Some people actually tend to recommend using a StreamReader to count lines (ouch) since they generally work with small files. The FileStream...

Lightweight Code Gen and mathematical equations.

Using lightweight code gen for dynamic scripting languages is cool and all, but imagine the possibilities for the language of mathematics. Sure you can try to write some generics that handle common tasks, perhaps a generic method or two, but lightweight...

DWC.Algorithms.NumberUtilities with the latest hopefuls, a test case runner, and some comments...

So the latest code prop does SByte, Byte, Int16, UInt16, and Int32 parsing. All deprecated methods have been moved to a secondary class to reduce the size of the primary class (statics and whatnot). I've added a licensing agreement, since I want to protect...

Following up on the benefits of continued use of int.Parse...

Alex Campbell followed up with some comments on his blog that he saw the continued use of int.Parse as acceptable because of it's additional parsing abilities to determine if a number truly was an integer. C# if(!FindFunction(IsNumeric)) { return "this...

Improving on System.Random for gaming and simulation

The algorithm for grabbing samples in the System.Random class comes from Numeric Recipes in C, Second Edition. They've made some small changes to how the algorithm is run, to either improve performance, or improve the random characteristics of the resulting...

Performance: Different methods for testing string input for numeric values...

So there was a blog entry about the VB .NET IsNumeric function today. The question was in regards to a C# equivalent. I have two things to say really. First, if you really want the IsNumeric function from VB you can always grab it out of Microsoft.VisualBasic...

Performance and Insight: For versus Foreach over a strongly typed array... Some things you might not know.

To give some background there was a post on one of the MS newsgroups about why a nested foreach statement looping over two arrays was slower than the equivalent code in a for loop. While everyone liked to point out, rather too quickly I might add, that...

Be careful what you switch for... (examining degenerate case statements, in the C# switch statement)

So what happens when you write a complex switch statement that doesn't contain contiguous case elements? Have you ever checked the IL to find out? I am going to examine a large number of switch statements, their performance ramifications, and their IL...

Want faster regular expressions? Maybe you should think about that IgnoreCase option...

Let me start with a disclaimer. RegexOptions.IgnoreCase is a very powerful option that allows you to match ignore character casing during matches irregardless of the currently running culture. In other words, this will allow you to take into account other...

Performance: If vs Switch in what we might call an extended usage scenario?

Alrighty, Darren Neimke gets me thinking again, by pointing out how a ToMilliseconds method can be implemented using a fall-through switch statement. Without really trying to break the semantics and without unrolling the code, I've tried to pit the switch...
More Posts Next page »