Exemple #1
0
        static void Main()
        {
            var bidictionary = new BiDictionary<int, int, string>();

            bidictionary.Add(1, 1, "AA");
            bidictionary.Add(1, 2, "AB");
            bidictionary.Add(1, 2, "AB");
            bidictionary.Add(2, 1, "BA");
            bidictionary.Add(2, 2, "BB");
            bidictionary.Add(2, 3, "BC");
            bidictionary.Add(3, 1, "CA");
            bidictionary.Add(3, 2, "CB");
            bidictionary.Add(3, 3, "CC");
            bidictionary.Add(3, 4, "CD");
            bidictionary.Add(3, 5, "CE");
            bidictionary.Add(3, 6, "CF");

            Console.WriteLine("Values by two keys:");
            Console.WriteLine(bidictionary[1, 1]);
            Console.WriteLine(bidictionary[1, 2]);
            Console.WriteLine(bidictionary[3, 2]);

            Console.WriteLine();
            var collectionByKey1 = bidictionary.GetByKey1(3);
            Console.WriteLine("All values with key1 = 3:");
            Console.WriteLine(string.Join(Environment.NewLine, collectionByKey1));

            Console.WriteLine();
            var collectionByKey2 = bidictionary.GetByKey2(2);
            Console.WriteLine("All values with key2 = 2:");
            Console.WriteLine(string.Join(Environment.NewLine, collectionByKey2));
        }
        public static void Main(string[] args)
        {
            var dict = new BiDictionary<int, int, string>();

            dict.Add(1, 1, "Pesho");
            dict.Add(1, 21, "Gosho");
            dict.Add(2, 1, "Stamat");
            dict.Add(1, 3, "Mariika");

            Console.WriteLine(dict[1, 3]);
            Console.WriteLine(dict[1, 1]);

            var collectionByKey2 = dict.GetByKey2(1);
            Console.WriteLine(string.Join(", ", collectionByKey2));
        }
    public static void Main(string[] args)
    {
        BiDictionary <int, string, decimal> biDictionary = FillBiDictionary();

        decimal[] searchByKey1 = biDictionary.GetByKey1(5).Take(20).ToArray <decimal>();

        Console.WriteLine("Values searched by key1:");
        PrintValuesCollection(searchByKey1);

        decimal[] searchByKey2 = biDictionary.GetByKey2("key2:" + 13).Take(20).ToArray <decimal>();

        Console.WriteLine(new string('*', 20));
        Console.WriteLine("Values searched by key2:");
        PrintValuesCollection(searchByKey2);

        decimal[] searchByBothKeys = biDictionary.GetByBothKeys(5, "key2:" + 13).Take(20).ToArray <decimal>();

        Console.WriteLine(new string('*', 20));
        Console.WriteLine("Values searched by both keys:");
        PrintValuesCollection(searchByBothKeys);
    }