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

// BagMaps - Project BagMap

using System;
using Calculus;

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

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

            Array<double> keyRangeB = M.Find("StringB");

            Console.WriteLine("{0}", M);
            Console.WriteLine("Key Range for {0} == {1}", "StringB", keyRangeB);

The indexer is used to place entries in the map. The method Find is used to search the map. The output is shown below.

Key Range for StringB == {2.5,4.5,5.5}