Map - Description


The generic class Map is a hash table of entries. The generic has two type parameters, K - the key type, and T - the data type. The generic class Map exists in the namespace Calculus (in assembly Calculus.dll).

When creating a map Map<K,T>, the key class K is expected to be equality comparable. There are two ways in which the comparer for class K can be specified:

  1. the class K may derive from IEquatable of K or
  2. the constructor Map - Comparer may be used to manually specify the equality comparer.

The declaration of the map class (in C#) is shown below.

[Serializable]
public class Map<K, T> : IDictionary<K,T>,
                         IEquatable<Map<K,T>>

Maps are serializable (interface ISerializable) and using the binary formatter, a map may be written to a file or other media.

Because maps implement the IEnumerable of KeyValue interface, maps may be written to and read from XML databases. This is in contrast to the builtin .Net Map class - which doesn't support XML.

Several definitions of the most important concept 'map' are possible. The definition adopted by Calculus is that a map separates the keys and the data. Map has an indexer.

The class Map is an unordered collection. When foreach is applied to a map, the entries are presented in random order. A similar but ordered concept is the class Dictionary.