Maps


A map is defined to be an unordered collection that has keys and values, where the keys are independent of the values. The key class will be often referred to as K and the value class will often be referred to as T. Thus, a map is a generic class of the form Map<K,T>. The K and the T are the generic class parameters. The next program demonstrates how to declare and load a map.

// Maps - Project Map

using System;
using Calculus;

namespace Transient
{
    class Program
    {
        static void Main(string[] args)
        {
            Map<string,double> M = new Map<string,double>();

            M["StringA"] = 1.5;
            M["StringB"] = 2.5;
            M["StringC"] = 3.5;

            Console.WriteLine("{0}", M);
            Console.WriteLine("M[\"{0}\"] == {1}", "StringB", M["StringB"]);  
        }
    }
}

The indexer is used to place entries in the map. The indexer is also used to search the map.