The Wagner Blog
Development Notes, News and Trivia









Subscribe to "The Wagner Blog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
 

 

Friday, June 07, 2002
 

Red Hat accuses Sun of Microsoft tactics. An executive charges Sun Microsystems with adopting the domineering methods of software giant Microsoft. Sun bridles at the comparison. [CNET News.com][Sam Gentile's Radio Weblog]


9:24:55 PM    

I saw this question on one of the .NET newsgroups today:

I am looping through a datareader, putting the value of a string column as both the key and value of a hashtable item using the add method. The data was ordered in the sql statement. When I traverse the hashtable the data is in random order. Can anyone tell me why this happens?

This isn't a surprising question, since hash tables in .NET serve much the same function that maps (and multimaps) did in standard C++. But their implementation is radically different.

The map in C++ is a balanced tree. That means that its average access for any data element is O(1/2 log n), and the worst case is O(log n). Binary trees always keep the data is sorted order, and the balanced nature of the trees is what gives you the O(log n) access rate. A side effect of this is that when you traverse the data, it's always in sorted order.

The hash table in .NET is ... a hash table. That means there's a lot of buckets, and some algorithm for turning the key into some bucket number. Given a key, you can find the appropriate bucket in O(1), and if you have enough buckets, your retrieval is also O(1). The reason you might end up worse than O(1) (worse case is O(n)) is if you don't have enough buckets, such that multiple things fall into one bucket. If there's more than one item in the bucket, then it's a linear search to find the right item.

Clearly, when you traverse the hash table, the items are going to be in what appears to be a random order (which is based on the values that result from the hashing algorithm). If you need sorted data, a hash table isn't for you.

Unfortunately, Microsoft didn't see fit to include a balanced tree container like the C++ map into the .NET framework. Good luck!

[The .NET Guy]

- Hmm do you suppose an array might have done a better job here?


9:22:35 PM    

Mono 0.12 is out! More classes! More working code! Better compiler! Faster runtime! Less bugs! You can get it Here (quick links: runtime and compiler/classes). [Mono Project News]

Congrats guys. Progress seems very speedy!

[The .NET Guy]
9:20:30 PM    


9:18:34 PM    

First draft of Web Service Description Usage Scenarios released by W3C [WebServices.Org] [Pythoz.com (Jørgen Larsen)]
9:16:43 PM    

England wins against Argentina 1 to 0. :( [From the Desktop of Dane Carlson]

- About time. I think England got whopped by Argentina in previous WorldCups. And the big rivalry started with the Argentine Team Captain spitting on the British Flag in 1966, and was later intensified when Argentinia invaded the Falkland Islands.


7:36:10 AM    

Colin Faulkingham hits paydirt. Do a view source on this slide show. It's all in one file. He just added an XSLT style sheet to my OPML file, nothing more. Fantastic, synergistic, low-tech, leading-edge. [Scripting News]

- Its kind of cute how Dave gets all excited.

 


7:32:57 AM    

Craig Gets Listed in Replay Suit. Craig Newmark, best known as namesake of the craigslist.org community sites, has a new role as lead plaintiff in a lawsuit against Hollywood's largest studios. By Joanna Glasner. [Wired News]
6:07:54 AM    

How to fully make use of System.Object [Sam Gentile's Radio Weblog]
6:07:13 AM    


Click here to visit the Radio UserLand website. © Copyright 2004 Thomas Wagner.
Last update: 5/2/2004; 4:44:08 PM.
This theme is based on the SoundWaves (blue) Manila theme.
June 2002
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
May   Jul