Ejemplo n.º 1
0
        public static void Main()
        {
            MultiHashDictionary <int, string, Inner> mdict = new MultiHashDictionary <int, string, Inner>
            {
                { 2, "to" },
                { 2, "deux" },
                { 2, "two" },
                { 20, "tyve" },
                { 20, "tyve" },
                { 20, "twenty" }
            };

            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            Console.WriteLine("mdict.Count (keys) is {0}",
                              ((IDictionary <int, Inner>)mdict).Count);
            Console.WriteLine("mdict[2].Count is {0}", mdict[2].Count);
            mdict.Remove(20, "tyve");
            mdict.Remove(20, "twenty");
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            Inner zwei = new Inner
            {
                "zwei"
            };

            mdict[2]  = zwei;
            mdict[-2] = zwei;
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            zwei.Add("kaksi");
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            Inner empty = new Inner();

            mdict[0] = empty;
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            Console.WriteLine("mdict contains key 0: {0}", mdict.Contains(0));
            mdict.Remove(-2);
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            zwei.Remove("kaksi");
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
            zwei.Clear();
            Console.WriteLine(mdict);
            Console.WriteLine("mdict.Count is {0}", mdict.Count);
        }
Ejemplo n.º 2
0
            public static void Run()
            {
                var mdict = new MultiHashDictionary <int, string> {
                    { 2, "to" },
                    { 2, "deux" },
                    { 2, "two" },
                    { 20, "tyve" },
                    { 20, "twenty" }
                };

                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                Console.WriteLine("mdict.Count (keys) is {0}",
                                  ((IDictionary <int, ICollection <string> >)mdict).Count);
                Console.WriteLine("mdict[2].Count is {0}", mdict[2].Count);
                mdict.Remove(20, "tyve");
                mdict.Remove(20, "twenty");
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                ICollection <string> zwei = new HashSet <string> {
                    "zwei"
                };

                mdict[2]  = zwei;
                mdict[-2] = zwei;
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                zwei.Add("kaksi");
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                ICollection <string> empty = new HashSet <string>();

                mdict[0] = empty;
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                Console.WriteLine("mdict contains key 0: {0}", mdict.Contains(0));
                mdict.Remove(-2);
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                zwei.Remove("kaksi");
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                zwei.Clear();
                Console.WriteLine(mdict);
                Console.WriteLine("mdict.Count is {0}", mdict.Count);
                Console.WriteLine("------------------------------");
            }