improve.dk
Just another mindless drone looking for the perfect stack
posts - 220, comments - 475

May 2008 Blog Posts


Generic Dijkstra's Algorithm

Written on Tuesday, May 13, 2008 by Mark S. Rasmussen in Development: .NET

Through various projects, I've had to do some shortest-path finding in a connected graph. An efficient and straight-forward way to do this is using Dijkstra's Algorithm. Notice that it'll only work for graphs with non negative path weights, like 2D maps for instance. While I've used the algorithm on several occasions, it's only now that I've rewritten it in generic form The code is pretty much self explanatory if you keep the pseudo code implementation next to it. using System; using System.Collections.Generic; using System.Linq; namespace Improve.Framework.Algorithms { public class Dijkstra<TNode> { /// <summary> /// Calculates the shortest route from a source node to a target node...

No comments | Write first comment
 

Programmers at Work

Written on Thursday, May 08, 2008 by Mark S. Rasmussen in Books

I just finished reading the book Programmers at Work by Susan Lammers. It's a unique book unlike most others I've read. Most of the books I read are practically oriented, how to do this, how to do that (in an abstract way, but still practical). Programmers at Work contains interviews with 19 of the most influential computer programmers, written in the early 80's. It's an eye opener how similar the though processes, scenarios and development ideas where back then to what we're used to today. They didn't have nearly the same facilities at hand, neither hardware...

No comments | Write first comment
 

Mapping datareader to objects using Reflection.Emit

Written on Friday, May 02, 2008 by Mark S. Rasmussen in Development: .NET

I've previously written of how to automatically map a DataTable into a strongly typed collection of objects. There's a problem though, it's not fast... I wanted to improve on it, and this is what I ended up with. The original method relied heavily on reflection to set the values directly. Reflection's bad in regards of speed, mkay? But reflection is not necessarily evil, you can do great good with it. Now, the problem with the original method is that each field is set using reflection for each row, that's [number of fields] * [number of rows] fields being set...

9 comments | Read comments