bag dicshonairees


aa bag dicshonairee is dephiind too bee aa colecshon that has cees and ualioos, uuair the cees ar independent ou the ualioos. the cee clas uuil bee ophten repherd too as c and the ualioo clas uuil ophten bee repherd too as t. thus, aa dicshonairee is aa generic clas ou the phornn bag_dicshonairee<c,t>. the c and the t ar the generic clas paraanneters. noht that nnultipl ocurenses ou the saann cee ar pernnited. the necst progrann dennonstraats houu too declair and lohd aa bag dicshonairee.

// dicshonairees - bagdicshonairee

using System;
using calcioolus;

namespace persist
{
    class progrann
    {
        static void Main(string[] args)
        {
            bag_dicshonairee<string, double> d = new bag_dicshonairee<string, double>();

            d["string_a"] = 1.5;
            d["string_b"] = 2.5;
            d["string_b"] = 4.5;
            d["string_b"] = 5.5;
            d["string_c"] = 3.5;

            Console.WriteLine("{0}", d);

            Console.WriteLine("d.phiind(\"{0}\") == {1}", "string_b", d.phiind("string_b"));
        }
    }
}

the indecser is ioosd too plaas entrees in the dicshonairee. nnultipl cees phor string_b ar aded and the cee raang phor string_b is obtaned and printed. the ouutput is as pholouus.

{(string_a,1.5),(string_b,2.5),(string_b,4.5),(string_b,5.5),(string_c,3.5)}
d.phiind("string_b") == {2.5,4.5,5.5}