Sunday, April 02, 2006

 

The search for intelligent C# containers

The well crafted C++ associative containers are missing in C#. While Microsoft introduced "generic collections" with ASP.NET 2.0, providing configurable element types, capabilities of these Microsoft C# classes are limited.

For example, the C# SortedDictionary class is superficially similar to the C++ map class. However, SortedDictionary methods lack equivalents to the C++ upper_bound and lower_bound; they are only able to identify an exact key match. Unlike the bidirectional iterators of a C++ map, C# is unable to traverse SortedDictionary nodes in the vicinity of an identified node. Its only enumeration passes through the entire collection.

Relief is available at a price. For a few hundred U.S. dollars, Recursion Software sells a "C# ToolKit" component package including an OrderedMap container functionally equivalent to the C++ map. Recursion's containers do not use templated declarations, so they are not type-safe like the C++ containers and the C# "generic collections."

One can wrap Recursion Software containers in C# "generic classes" and write type-safe C# code with them. As of early 2006 this appears to be the best solution. Unfortunately there are far fewer components available for C# than in the more established Java, C++ and Visual Basic markets.

Note: Recursion Software updated its C# Toolkit in March, 2006. With the update its OrderedMap and OrderedSet classes provide O(log n) performance on all basic operations. These classes support either unique or multiple occurrence keys and are now equivalent in performance to the C++ map, multimap, set and multiset.

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]