Пример #1
0
        static void Main()
        {
            var biDictionary =
                new BiDictionary<int, string, DateTime>(
                    new MultiDictionary<int, Triple<int, string, DateTime>>(true),
                    new MultiDictionary<string, Triple<int, string, DateTime>>(true),
                    new MultiDictionary<CompositeKey<int, string>, Triple<int, string, DateTime>>(true));

            biDictionary.AddByFirstKey(1, new Triple<int, string, DateTime>(1, "one", DateTime.Today));
            biDictionary.AddBySecondKey("two", new Triple<int, string, DateTime>(2, "two", DateTime.Today));
            biDictionary.AddByCompositeKey(new CompositeKey<int, string>(3, "three"), new Triple<int, string, DateTime>(3, "three", DateTime.Today));

            Console.WriteLine("Elements: " + biDictionary.Count);
            Console.WriteLine("T1 keys: " + string.Join(", ", biDictionary.KeysT1));
            Console.WriteLine("T2 keys: " + string.Join(", ", biDictionary.KeysT2));
            Console.WriteLine("Composite keys: " + string.Join(", ", biDictionary.KeysComposite));

            foreach (var key in biDictionary)
            {
                foreach (var triple in key.Value)
                {
                    Console.WriteLine($"Triple: K1: {triple.FirstKey}; K2: {triple.SecondKey}; V: {triple.Value}");
                }
            }
        }
    /* Task 3: 
     * Implement a class BiDictionary<K1,K2,T> that allows adding triples {key1, key2, value} and 
     * fast search by key1, key2 or by both key1 and key2. Note: multiple values can be stored for given key.
     */

    //Note: since removing of keys is not requested I have not implemented it. 

    static void Main(string[] args)
    {
        var biDictionary = new BiDictionary<string, int, int>();

        biDictionary.Add("Pesho", 4);
        biDictionary.Add("Pesho", 5);
        biDictionary.Add("Pesho", 3);
        biDictionary.Add(23, 6);
        biDictionary.Add("Maria", 13, 5);
        biDictionary.Add("Maria", 13, 2);
        biDictionary.Add("Maria", 13, 4);
        biDictionary.Add("Maria", 13, 6);

        foreach (var item in biDictionary.GetValueByFirstKey("Pesho"))
        {
            Console.WriteLine(item);
        }

        foreach (var item in biDictionary.GetValueBySecondKey(23))
        {
            Console.WriteLine(item);
        }

        foreach (var item in biDictionary.GetValueByBothKeys("Maria", 13))
        {
            Console.WriteLine(item);
        }
    }
        static void Main(string[] args)
        {
            BiDictionary<string, string, string> dictionary = new BiDictionary<string, string, string>();
            dictionary.Add("Ivko", "mivko", "Ivko Mivko");
            dictionary.Add("Telerik", "Academy", "Telerik aka");
            dictionary.Add("Telerik", "asdf", "Peter Petrov");
            dictionary.Add("asdf", "Academy", "Dancho Danchev");


            var fromSofia = dictionary.FindByFistKey("Ivko");
            foreach (var item in fromSofia)
            {
                Console.WriteLine(item);
            }

            var manGender = dictionary.FindBySecondKey("asdf");
            foreach (var item in manGender)
            {
                Console.WriteLine(item);
            }

            var manFromPlovdiv = dictionary.FindByBothKeys("Telerik", "Academy");
            foreach (var item in manFromPlovdiv)
            {
                Console.WriteLine(item);
            }
        }
Пример #4
0
        static void Main()
        {
            var distances = new BiDictionary<string, string, int>();

            distances.Add("Sofia", "Varna", 443);
            distances.Add("Sofia", "Varna", 468);
            distances.Add("Sofia", "Varna", 490);
            distances.Add("Sofia", "Plovdiv", 145);
            distances.Add("Sofia", "Bourgas", 383);
            distances.Add("Plovdiv", "Bourgas", 253);
            distances.Add("Plovdiv", "Bourgas", 292);

            var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383]
            foreach (var distance in distancesFromSofia)
            {
                System.Console.WriteLine(distance);
            }
            var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292]
            var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292]
            var distancesRousseVarna = distances.Find("Rousse", "Varna"); // []
            var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490]

            distances.Remove("Sofia", "Varna"); // true

            var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383]
            var distancesToVarna = distances.FindByKey2("Varna"); // []
            var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // []
        }
        public static void Main()
        {
            var biDictionary = new BiDictionary<bool, int, string>();

            biDictionary.Add(true, 18, "Ivan Petrov");
            biDictionary.Add(false, 18, "Gergana Mihova");
            biDictionary.Add(true, 30, "Petkan Iliev");
            biDictionary.Add(false, 25, "Ani Petrova");
            biDictionary.Add(true, 45, "Georgi Ivanov");
            biDictionary.Add(true, 45, "Pesho Goshov");
            biDictionary.Add(true, 45, "Miho Mihov");
            biDictionary.Add(false, 28, "Petranka Petrova");
            biDictionary.Add(false, 28, "Ivanka Ivanova");
            biDictionary.Add(false, 28, "Pepa Petrova");

            // all men
            Console.WriteLine(biDictionary.FindByFirstKey(true));

            // all 45 years old
            Console.WriteLine(biDictionary.FindBySecondKey(45));

            // all women 28 years old
            Console.WriteLine(biDictionary.FindByBothKeys(false, 28));

            // all 50 years old men
            Console.WriteLine(biDictionary.FindByBothKeys(true, 50)); // empty collection !!!
        }
Пример #6
0
        static void Main(string[] args)
        {
            try
            {
                const int NumberOfItems = 10;
                BiDictionary<string, string, int> collection =
                    new BiDictionary<string, string, int>();

                for (int i = 0; i < NumberOfItems; i++)
                {
                    collection.Add("K1" + i, "K2" + i, i);
                }

                for (int i = 0; i < NumberOfItems; i++)
                {
                    collection.Add("K1" + i, "K2" + i, i * 7);
                }

                Console.WriteLine(collection.Find("K29").Count());
                Console.WriteLine(collection.Find("K19", "K29").Count());
                Console.WriteLine(collection.Find("K199").Count());
            }
            catch (InvalidOperationException iex)
            {
                Console.WriteLine(iex.Message);
            }
        }
Пример #7
0
        static void Main()
        {
            var dict = new BiDictionary<int, string, int>();

            dict.Add(25, "10", 1);
            dict.Add(25, "5", 2);
            dict.Add(15, "3", 3);
            dict.Add(15, "1", 4);
            dict.Add(15, "2", 5);
            dict.Add(12, "10", 5);
            dict.Add(25, "10", 6);
            dict.Add(12, "10", 7);
            dict.Add(25, "10", 8);

            Console.WriteLine("First Dictionary");
            Console.WriteLine(dict[5]);
            Console.WriteLine(dict[25]);
            Console.WriteLine(dict[15]);
            Console.WriteLine(dict["10"]);
            Console.WriteLine("{{{0}}}", string.Join(",", dict[25, "10"]));

            var dict2 = new BiDictionary<int, int, int>();
            dict2.Add(25, 10, 1);
            dict2.Add(25, 10, 1);
            dict2.Add(25, 10, 1);
            dict2.Add(25, 10, 2);
            dict2.Add(25, 10, 2);
            Console.WriteLine("Second Dictionary");

            //This cannot be called because both keys are ints
            //Console.WriteLine(dict2[25]);
            Console.WriteLine("{{{0}}}", string.Join(",", dict2[25, 10]));
        }
Пример #8
0
        public static void Main()
        {
            BiDictionary<string, int, string> biDictionary = new BiDictionary<string, int, string>(allowDuplicateValues: true);

            Random rand = new Random();
            for (int i = 0; i < 1000; i++)
            {
                biDictionary.Add("Item" + rand.Next(1, 30), rand.Next(10, 1000), "SecondItem" + rand.Next(40, 100));
            }

            Console.WriteLine("Test GET: ");
            Console.WriteLine(string.Join(" ", biDictionary.GetByFirstKey("Item3")));
            Console.WriteLine(string.Join(" ", biDictionary.GetBySecondKey(100)));
            Console.WriteLine(string.Join(" ", biDictionary.GetByFirstAndSecondKey("Item50", 300)));

            Console.Write("Dictionary Count: ");
            Console.WriteLine(biDictionary.Count);

            biDictionary.RemoveByFirstKey("Item10");
            Console.Write("Dictionary Count: ");
            Console.WriteLine(biDictionary.Count);

            biDictionary.RemoveBySecondKey(500);
            Console.Write("Dictionary Count: ");
            Console.WriteLine(biDictionary.Count);

            biDictionary.RemoveByFirstAndSecondKey("Item20", 200);
            Console.Write("Dictionary Count: ");
            Console.WriteLine(biDictionary.Count);
        }
Пример #9
0
 static OperatorEnumExtension()
 {
     codes = new BiDictionary <VisibilityExpression.OperatorEnum, PdfName>();
     codes[VisibilityExpression.OperatorEnum.And] = PdfName.And;
     codes[VisibilityExpression.OperatorEnum.Not] = PdfName.Not;
     codes[VisibilityExpression.OperatorEnum.Or]  = PdfName.Or;
 }
Пример #10
0
 static ViewerPreferencesPaperModeEnumExtension()
 {
     codes = new BiDictionary <ViewerPreferences.PaperModeEnum, PdfName>();
     codes[ViewerPreferences.PaperModeEnum.Simplex]         = PdfName.Simplex;
     codes[ViewerPreferences.PaperModeEnum.DuplexShortEdge] = PdfName.DuplexFlipShortEdge;
     codes[ViewerPreferences.PaperModeEnum.DuplexLongEdge]  = PdfName.DuplexFlipLongEdge;
 }
        public static void Main()
        {
            IBiDictionary<string, int, string> dictionaryPower = new BiDictionaryPC<string, int, string>();
            IBiDictionary<string, int, string> dictionary = new BiDictionary<string, int, string>();

            ReadDataFromFile("../../input.txt", dictionaryPower);
            ReadDataFromFile("../../input.txt", dictionary);

            var searchByFirstKey = dictionaryPower.SearchByFirstKey("Plovdiv");
            var searchByFirstKey1 = dictionary.SearchByFirstKey("Plovdiv");
            Console.WriteLine("Search by name:");
            Console.WriteLine(string.Join(", ", searchByFirstKey));
            Console.WriteLine();
            Console.WriteLine(string.Join(", ", searchByFirstKey1));

            var searchBySecondKey = dictionaryPower.SearchBySecondKey(23);
            Console.WriteLine("Search by age:");
            Console.WriteLine(string.Join(", ", searchBySecondKey));

            var serarchByTwoKeys = dictionaryPower.SearchByTwoKeys("Plovdiv", 20);
            var serarchByTwoKeys1 = dictionary.SearchByTwoKeys("Plovdiv", 20);
            Console.WriteLine("Search by sity and age:");
            Console.WriteLine(string.Join(", ", serarchByTwoKeys));
            Console.WriteLine();
            Console.WriteLine(string.Join(", ", serarchByTwoKeys1));
        }
Пример #12
0
        public void CtorShouldValidate()
        {
            var codeLetterLookup = new BiDictionary <int, string>();

            codeLetterLookup.Add(0, "AA");
            codeLetterLookup.Add(1, "BB");

            var fullNameLookup = new Dictionary <string, string>()
            {
                { "AA", "Country A" },
                { "XX", "Country X" }
            };

            var manager = new CountryCodeManager(codeLetterLookup, fullNameLookup);

            Assert.AreEqual(2, manager.CodeToLetterLookup.Count);
            Assert.IsTrue(manager.CodeToLetterLookup.Contains(
                              new KeyValuePair <int, string>(0, "AA")));
            Assert.IsTrue(manager.CodeToLetterLookup.Contains(
                              new KeyValuePair <int, string>(1, "BB")));

            Assert.AreEqual(2, manager.FullNameLookup.Count);
            Assert.IsTrue(manager.FullNameLookup.Contains(
                              new KeyValuePair <string, string>("AA", "Country A")));
            Assert.IsTrue(manager.FullNameLookup.ContainsKey("BB"));
        }
Пример #13
0
        static void Main(string[] args)
        {
            var biDict = new BiDictionary<int, string, string>();

            for (int i = 0; i < 20; i++)
            {
                var name = "Pesho" + i;
                var result = "Result" + i;
                biDict.Add(i, name, result);
            }

            var firstTry = biDict.FindByFirstKey(1);
            foreach (var item in firstTry)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("----------");

            var secondTry = biDict.FindBySecondKey("Pesho2");
            foreach (var item in secondTry)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("----------");

            var thirdTry = biDict.FindByTwoKeys(2, "Pesho2");
            foreach (var item in thirdTry)
            {
                Console.WriteLine(item);
            }
        }
Пример #14
0
        public static void Main()
        {
            var multi = new BiDictionary<int, string, string>();

            multi.Add(1, "one", "firstElement");

            multi.Add(1, "two", "mixed");

            multi.Add(2, "two", "secondElement");

            Console.WriteLine("first key :");
            var result1 = multi.FindByFirstKey(1);
            foreach (var item in result1)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("second key :");
            var result2 = multi.FindBySecondKey("two");
            foreach (var item in result2)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("both keys :");
            var result3 = multi.FindByBothKeys(1, "two");
            foreach (var item in result3)
            {
                Console.WriteLine(item);
            }
        }
 static StandardFileSystemEnumExtension(
     )
 {
     codes = new BiDictionary <FullFileSpecification.StandardFileSystemEnum, PdfName>();
     codes[FullFileSpecification.StandardFileSystemEnum.Native] = null;
     codes[FullFileSpecification.StandardFileSystemEnum.URL]    = PdfName.URL;
 }
        public void RemoveAll()
        {         //****************************************
            var Seed   = Environment.TickCount;
            var Random = new Random(Seed);
            //****************************************

            var Dictionary = new Dictionary <int, int>(1024);

            foreach (var(Left, Right) in YieldRandom(Random, 1024))
            {
                Dictionary.Add(Left, Right);
            }

            var Records = new BiDictionary <int, int>(Dictionary);

            //****************************************

            Records.RemoveAll((pair) => { if (Random.Next() > int.MaxValue / 2)
                                          {
                                              return(Dictionary.Remove(pair.Key));
                                          }
                                          return(false); });

            //****************************************

            CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match. Bad Seed was {0}", Seed);

            foreach (var MyPair in Dictionary)
            {
                Assert.IsTrue(Records.TryGetRight(MyPair.Key, out var Value));
                Assert.AreEqual(MyPair.Value, Value);
            }
        }
        public void RemoveRange()
        {         //****************************************
            var Seed   = Environment.TickCount;
            var Random = new Random(Seed);
            //****************************************

            var Dictionary = new Dictionary <int, int>(1024);

            foreach (var(Left, Right) in YieldRandom(Random, 1024))
            {
                Dictionary.Add(Left, Right);
            }

            var Records = new BiDictionary <int, int>(Dictionary);

            //****************************************

            foreach (var MyResult in Records.Skip(256).Take(256))
            {
                Dictionary.Remove(MyResult.Key);
            }

            Records.RemoveRange(256, 256);

            //****************************************

            CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match. Bad Seed was {0}", Seed);

            foreach (var MyPair in Dictionary)
            {
                Assert.IsTrue(Records.TryGetRight(MyPair.Key, out var Value));
                Assert.AreEqual(MyPair.Value, Value);
            }
        }
        public void GetKeyMissing()
        {         //****************************************
            var MyRecords = new BiDictionary <int, int>();

            //****************************************

            MyRecords[10] = 42;

            //****************************************

            try
            {
                var Pair = MyRecords[42];

                Assert.Fail("Key found");
            }
            catch (KeyNotFoundException)
            {
            }

            try
            {
                var Pair = MyRecords.Inverse[10];

                Assert.Fail("Key found");
            }
            catch (KeyNotFoundException)
            {
            }
        }
        public void PrePopulate()
        {         //****************************************
            var Seed   = Environment.TickCount;
            var Random = new Random(Seed);
            //****************************************

            var Dictionary = new Dictionary <int, int>(1024);

            foreach (var(Left, Right) in YieldRandom(Random, 1024))
            {
                Dictionary.Add(Left, Right);
            }

            var Records = new BiDictionary <int, int>(Dictionary);

            //****************************************

            Assert.AreEqual(1024, Records.Count, "Count incorrect. Bad Seed was {0}", Seed);

            CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match. Bad Seed was {0}", Seed);

            foreach (var MyPair in Dictionary)
            {
                Assert.IsTrue(Records.TryGetRight(MyPair.Key, out var Value));
                Assert.AreEqual(MyPair.Value, Value);
            }
        }
        [Test()]        //, Repeat(2)]
        public void AddRemoveCollide()
        {
            var Random  = Initialise();
            var Records = new BiDictionary <Collider, Collider>();

            foreach (var(Left, Right) in YieldRandom(Random, 16))
            {
                Records.Add(Left, Right);
            }

            var Inputs = YieldRandom(Random, 1024).ToQueue();

            for (var Index = 0; Index < 1024; Index++)
            {
                if (Index % 10 >= 5 && Records.Count > 0)
                {
                    var Key = Records.Get(Random.Next(0, Records.Count)).Key;

                    Records.Remove(Key);
                }
                else
                {
                    Records.Add(ToColliderPair(Inputs.Dequeue()));
                }
            }
        }
        public void GetIndexOutOfRange()
        {         //****************************************
            var MyRecords = new BiDictionary <int, int>();

            //****************************************

            MyRecords[10] = 42;

            //****************************************

            try
            {
                var Pair = ((IList <KeyValuePair <int, int> >)MyRecords)[1];

                Assert.Fail("Key found");
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            try
            {
                var Pair = ((IList <KeyValuePair <int, int> >)MyRecords)[-1];

                Assert.Fail("Key found");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
        private static void ConfigureCompositionRoot(
            string connectionString,
            IExecutionContextAccessor executionContextAccessor,
            ILogger logger,
            EmailsConfiguration emailsConfiguration,
            string textEncryptionKey,
            IEmailSender emailSender)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterModule(new LoggingModule(logger.ForContext("Module", "UserAccess")));

            var loggerFactory = new SerilogLoggerFactory(logger);

            containerBuilder.RegisterModule(new DataAccessModule(connectionString, loggerFactory));
            containerBuilder.RegisterModule(new DomainModule());
            containerBuilder.RegisterModule(new ProcessingModule());
            containerBuilder.RegisterModule(new EventsBusModule());
            containerBuilder.RegisterModule(new MediatorModule());

            var domainNotificationsMap = new BiDictionary <string, Type>();

            domainNotificationsMap.Add("NewUserRegisteredNotification", typeof(NewUserRegisteredNotification));
            containerBuilder.RegisterModule(new OutboxModule(domainNotificationsMap));

            containerBuilder.RegisterModule(new QuartzModule());
            containerBuilder.RegisterModule(new EmailModule(emailsConfiguration, emailSender));
            containerBuilder.RegisterModule(new SecurityModule(textEncryptionKey));

            containerBuilder.RegisterInstance(executionContextAccessor);

            _container = containerBuilder.Build();

            UserAccessCompositionRoot.SetContainer(_container);
        }
Пример #23
0
        static void Main()
        {
            var dict = new BiDictionary<string, int, string>();

            dict.Add("pesho", 1, "rabbit");
            dict.Add("bai ivan", 2, "frog");
            dict.Add("maria", 3, "bat");
            dict.Add("maria", 2, "donkey");
            dict.Add("pesho", 3, "bear");
            dict.Add("bai ivan", 1, "hippo");

            var peshos = dict.FindByKey1("pesho");

            foreach (var item in peshos)
            {
                Console.WriteLine(item);
            }

            var marias = dict.FindByKey1AndKey2("maria", 3);

            foreach (var item in marias)
            {
                Console.WriteLine(item);
            }

        }
Пример #24
0
        private static void Main()
        {
            var bidictionary = new BiDictionary<string, int, string>(true);

            bidictionary.Add("kircho", 1, "JavaScript");
            bidictionary.Add("mircho", 2, "Java");
            bidictionary.Add("svircho", 3, "C#");
            bidictionary.Add("shosho", 3, "C#");
            bidictionary.Add("gosho", 3, "Coffee");
            bidictionary.Add("tosho", 1, "Python");

            Console.WriteLine(string.Join(" ", bidictionary.GetByFirstKey("mircho")));
            Console.WriteLine(string.Join(" ", bidictionary.GetBySecondKey(3)));
            Console.WriteLine(string.Join(" ", bidictionary.GetByFirstAndSecondKey("svircho", 3)));

            Console.WriteLine(bidictionary.Count);

            bidictionary.RemoveByFirstKey("gosho");
            Console.WriteLine(bidictionary.Count);

            bidictionary.RemoveBySecondKey(3);
            Console.WriteLine(bidictionary.Count);

            bidictionary.RemoveByFirstAndSecondKey("tosho", 1);
            Console.WriteLine(bidictionary.Count);
        }
Пример #25
0
 public void BiDictionaryRemove_Test()
 {
     var dictionary = new BiDictionary<object, object>();
     dictionary.Add("test", "test");
     dictionary.Remove("test");
     Assert.Empty(dictionary);
 }
Пример #26
0
 static UserTypeEnumExtension()
 {
     codes = new BiDictionary <Layer.UserTypeEnum, PdfName>();
     codes[Layer.UserTypeEnum.Individual]   = PdfName.Ind;
     codes[Layer.UserTypeEnum.Organization] = PdfName.Org;
     codes[Layer.UserTypeEnum.Title]        = PdfName.Ttl;
 }
        public static void Main()
        {
            string decorationLine = new string('-', Console.WindowWidth);
            Console.Write(decorationLine);
            Console.WriteLine("***Presenting the functionality of the data structure 'BiDictionary' - allows");
            Console.WriteLine("adding values by two keys, searching by a single key or by both keys and");
            Console.WriteLine("removing values by both keys***");
            Console.Write(decorationLine);

            BiDictionary<string, string, Person> peopleDictionary =
                new BiDictionary<string, string, Person>();

            Console.WriteLine("---Test add operation---");
            foreach (Person person in people)
            {
                peopleDictionary.Add(person.FirstName, person.LastName, person);
            }

            Console.WriteLine("Count after addition: {0}", peopleDictionary.Count);
            Console.WriteLine();

            Console.WriteLine("---Test get values by first key---");
            string firstName = "Gosho";
            Console.WriteLine("All people with first name '{0}' are:", firstName);
            PrintPeopleOnConsole(peopleDictionary.GetByFirstKey(firstName));
            Console.WriteLine();

            Console.WriteLine("---Test get values by second key---");
            string lastName = "Peshov";
            Console.WriteLine("All people with last name '{0}' are:", lastName);
            PrintPeopleOnConsole(peopleDictionary.GetBySecondKey(lastName));
            Console.WriteLine();

            Console.WriteLine("---Test get values by first key and second key---");
            string firstKey = "Gosho";
            string secondKey = "Goshov";
            Console.WriteLine("All people with first name '{0}' and last name '{1}' are:",
                firstKey,
                secondKey);
            PrintPeopleOnConsole(peopleDictionary.GetByBothKeys(firstKey, secondKey));
            Console.WriteLine();

            Console.WriteLine("---Test remove operation---");
            Console.WriteLine("Removing all people with first key '{0}' and second key '{1}'",
                firstKey,
                secondKey);
            peopleDictionary.Remove(firstKey, secondKey);
            Console.WriteLine("Count of people after removal: {0}", peopleDictionary.Count);
            Console.WriteLine("Count of people with first name '{0}' after removal: {1}",
                firstKey,
                peopleDictionary.GetByFirstKey(firstKey).Count);
            Console.WriteLine("Count of people with last name '{0}' after removal: {1}",
                secondKey,
                peopleDictionary.GetBySecondKey(secondKey).Count);
            Console.WriteLine();

            Console.WriteLine("---Test clear operation---");
            peopleDictionary.Clear();
            Console.WriteLine("Count of people after clearing the dictionary: {0}", peopleDictionary.Count);
        }
 static OffscreenBehaviorEnumExtension()
 {
     codes = new BiDictionary <MediaScreenParameters.Viability.FloatingWindowParametersObject.OffscreenBehaviorEnum, PdfInteger>();
     codes[MediaScreenParameters.Viability.FloatingWindowParametersObject.OffscreenBehaviorEnum.None]      = new PdfInteger(0);
     codes[MediaScreenParameters.Viability.FloatingWindowParametersObject.OffscreenBehaviorEnum.Adapt]     = new PdfInteger(1);
     codes[MediaScreenParameters.Viability.FloatingWindowParametersObject.OffscreenBehaviorEnum.NonViable] = new PdfInteger(2);
 }
Пример #29
0
        static void Main(string[] args)
        {
            BiDictionary<string, string, string> dictionary = new BiDictionary<string, string, string>();
            dictionary.Add("Lovech", "man", "Georgi Georgiev");
            dictionary.Add("Lovech", "woman", "Nina Todorova");
            dictionary.Add("Lovech", "woman", "Martina Nikolova");
            dictionary.Add("Sofia", "woman", "Elizabet Sokolova");
            dictionary.Add("Lovech", "man", "Tosho Kyltyrista");

            Console.WriteLine("People from Lovech:");
            foreach (var item in dictionary.FindByFistKey("Lovech"))
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();
            Console.WriteLine("Girls:");
            var girls = dictionary.FindBySecondKey("woman");
            foreach (var girl in girls)
            {
                Console.WriteLine(girl);
            }

            Console.WriteLine();
            Console.WriteLine("Me and Tosho");
            foreach (var person in dictionary.FindByBothKeys("Lovech", "man"))
            {
                Console.WriteLine(person);
            }
        }
Пример #30
0
        public void ReadDictionary(BinBuffer bb)
        {
            int modAmt = bb.ReadByte();

            for (int i = 0; i < modAmt; i++)
            {
                Mods.Add(bb.ReadString(), bb.ReadByte());
            }

            for (int i = 0; i < modAmt; i++)
            {
                ModID mid = bb.ReadByte();

                var modObjs = new BiDictionary <ObjName, ObjID>();

                short objAmt = bb.ReadInt16();

                for (int j = 0; j < objAmt; j++)
                {
                    modObjs.Add(bb.ReadString(), bb.ReadUInt16());
                }

                ModObjects.Add(mid, modObjs);
            }
        }
Пример #31
0
        public void TestAddOrReplace()
        {
            var testBiDictionary = new BiDictionary <int, string>();

            testBiDictionary.AddOrReplace(0, "Value1");
            Assert.Equal("Value1", testBiDictionary[0]);
            Assert.Equal(0, testBiDictionary["Value1"]);

            testBiDictionary.AddOrReplace(2, "Value10");
            Assert.Equal("Value10", testBiDictionary[2]);
            Assert.Equal(2, testBiDictionary["Value10"]);

            testBiDictionary.AddOrReplace(2, "Value2");
            Assert.Equal("Value2", testBiDictionary[2]);
            Assert.Equal(2, testBiDictionary["Value2"]);
            Assert.Equal(2, testBiDictionary.Firsts.Count);
            Assert.Equal(2, testBiDictionary.Seconds.Count);

            testBiDictionary.AddOrReplace(3, "Value3");
            Assert.Equal("Value3", testBiDictionary[3]);
            Assert.Equal(3, testBiDictionary["Value3"]);

            testBiDictionary.AddOrReplace(10, "Value3");
            Assert.Equal("Value3", testBiDictionary[10]);
            Assert.Equal(10, testBiDictionary["Value3"]);
            Assert.Equal(3, testBiDictionary.Firsts.Count);
            Assert.Equal(3, testBiDictionary.Seconds.Count);
        }
        public static void Main()
        {
            var biDict = new BiDictionary<string, string, List<int>>();

            biDict.Add("Ivan", "DSA", new List<int>() { 100, 20, 30 });
            biDict.Add("Pesho", "HQC", new List<int>() { 10, 40, 25 });
            biDict.Add("Gosho", "DSA", new List<int>() { 55, 66, 77 });
            biDict.Add("Gosho", "HQC", new List<int>() { 5, 6, 7 });

            Console.WriteLine("Searching Pesho's scores");
            var result1 = biDict.FindByFirstKey("Pesho");
            foreach (var item in result1)
            {
                Console.WriteLine(string.Join(", ", item));
            }

            Console.WriteLine("--------------------------------");
            Console.WriteLine("Searching for all scores in DSA");
            var result2 = biDict.FindBySecondKey("DSA");
            foreach (var item in result2)
            {
                Console.WriteLine(string.Join(", ", item));
            }

            Console.WriteLine("--------------------------------");
            Console.WriteLine("Searching for DSA's scores of Gosho");
            var result3 = biDict.FindByBothKeys("Gosho", "DSA");
            foreach (var item in result3)
            {
                Console.WriteLine(string.Join(", ", item));
            }
        }
Пример #33
0
    public static void Main()
    {
        var bdict = new BiDictionary<string, int, Person>();

        var people = new[]
        {
            new Person() { Name = "Peter", Age = 20, Town = "Sofia" },
            new Person() { Name = "Peter", Age = 20, Town = "Varna" },
            new Person() { Name = "Peter", Age = 25, Town = "Varna" },
            new Person() { Name = "Billy", Age = 20, Town = "Sofia" },
        };

        // Add people to dictionary
        foreach (var person in people)
        {
            // key1 (name), key2 (age), value (person)
            bdict.Add(person.Name, person.Age, person);
        }

        // Print all people from dictionary
        Console.WriteLine("All people in the BiDictionary:");
        foreach (var triple in bdict)
        {
            Console.WriteLine(string.Join(Environment.NewLine, triple.Item3));
        }

        // Test the dictionary by searching by key1 (name), key2 (age) and both key1 and key2
        Console.WriteLine("All people named Peter: {0}", string.Join(", ", bdict.GetByK1("Peter")));
        Console.WriteLine("All people at age 20: {0}", string.Join(", ", bdict.GetByK2(20)));
        Console.WriteLine("All people at age 20, named Peter: {0}", string.Join(", ", bdict.GetByBoth("Peter", 20)));
    }
Пример #34
0
        static void Main(string[] args)
        {
            BiDictionary<string, string, string> dictionary = new BiDictionary<string, string, string>();
            dictionary.Add("Sofia", "man", "Ivo Ivanov");
            dictionary.Add("Sofia", "woman", "Maria Ivanova");
            dictionary.Add("Plovdiv", "man", "Peter Petrov");
            dictionary.Add("Plovdiv", "woman", "Lili Georgieva");
            
            Console.WriteLine("\nAll from Sofia");
            var fromSofia = dictionary.FindByFistKey("Sofia");
            foreach (var item in fromSofia)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nAll man");
            var manGender = dictionary.FindBySecondKey("man");
            foreach (var item in manGender)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nAll Plovdiv and man");
            var manFromPlovdiv = dictionary.FindByBothKeys("Plovdiv", "man");
            foreach (var item in manFromPlovdiv)
            {
                Console.WriteLine(item);
            }
        }
 static BaseStateEnumExtension()
 {
     codes = new BiDictionary <LayerConfiguration.BaseStateEnum, PdfName>();
     codes[LayerConfiguration.BaseStateEnum.On]        = PdfName.ON;
     codes[LayerConfiguration.BaseStateEnum.Off]       = PdfName.OFF;
     codes[LayerConfiguration.BaseStateEnum.Unchanged] = PdfName.Unchanged;
 }
    static void Main()
    {
        BiDictionary<string, string, int> people =
            new BiDictionary<string, string, int>(true);
        people.AddItem("Gosho", "Bozhilov", 15);
        people.AddItem("Matey", "Kaziiski", 15);
        people.AddItem("Ivan", "Kaziiski", 17);
        people.AddItem("Ivan", "Petrov", 55);
        people.AddItem("Ivan", "Kaziiski", 12);

        var bykey1 = people.GetElementsByKey1("Ivan");
        foreach (var item in bykey1)
        {
            Console.WriteLine(item.key1 + " " + item.key2 + ", age: " + item.value);
        }

        Console.WriteLine("-------------------------");

        var bykey2 = people.GetElementsByKey2("Kaziiski");
        foreach (var item in bykey2)
        {
            Console.WriteLine(item.key1 + " " + item.key2 + ", age: " + item.value);
        }

        Console.WriteLine("-------------------------");

        var bykey1and2 = people.GetElementsByKey1AndKey2("Ivan", "Kaziiski");

        foreach (var item in bykey1and2)
        {
            Console.WriteLine(item.key1 + " " + item.key2 + ", age: " + item.value);
        }
    }
Пример #37
0
 static void Main(string[] args)
 {
     var distances = new BiDictionary<string, string, int>();
     distances.Add("Sofia", "Varna", 443);
     distances.Add("Sofia", "Varna", 468);
     distances.Add("Sofia", "Varna", 490);
     distances.Add("Sofia", "Plovdiv", 145);
     distances.Add("Sofia", "Bourgas", 383);
     distances.Add("Plovdiv", "Bourgas", 253);
     distances.Add("Plovdiv", "Bourgas", 292);
     var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383]
     Print(distancesFromSofia);
     var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292]
     Print(distancesToBourgas);
     var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292]
     Print(distancesPlovdivBourgas);
     var distancesRousseVarna = distances.Find("Rousse", "Varna"); // []
     Print(distancesRousseVarna);
     var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490]
     Print(distancesSofiaVarna);
     distances.Remove("Sofia", "Varna"); // true
     var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383]
     Print(distancesFromSofiaAgain);
     var distancesToVarna = distances.FindByKey2("Varna"); // []
     Print(distancesToVarna);
     var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // []
     Print(distancesSofiaVarnaAgain);
 }
 static ResizeBehaviorEnumExtension()
 {
     codes = new BiDictionary <MediaScreenParameters.Viability.FloatingWindowParametersObject.ResizeBehaviorEnum, PdfInteger>();
     codes[MediaScreenParameters.Viability.FloatingWindowParametersObject.ResizeBehaviorEnum.None] = new PdfInteger(0);
     codes[MediaScreenParameters.Viability.FloatingWindowParametersObject.ResizeBehaviorEnum.AspectRatioLocked] = new PdfInteger(1);
     codes[MediaScreenParameters.Viability.FloatingWindowParametersObject.ResizeBehaviorEnum.Free] = new PdfInteger(2);
 }
Пример #39
0
 static StateModeEnumExtension()
 {
     codes = new BiDictionary <SetLayerState.StateModeEnum, PdfName>();
     codes[SetLayerState.StateModeEnum.On]     = PdfName.ON;
     codes[SetLayerState.StateModeEnum.Off]    = PdfName.OFF;
     codes[SetLayerState.StateModeEnum.Toggle] = PdfName.Toggle;
 }
        public static void Main()
        {
            var dictionary = new BiDictionary<int, char, string>();
            dictionary.Add(1, 'a', "pesho");
            dictionary.Add(2, 'b', "gosho");
            dictionary.Add(1, 'c', "ivancho");
            dictionary.Add(3, 'c', "mariika");

            // searching by first key
            var firstKey = 1;
            var resultsByFirstKey = dictionary.Search(firstKey);
            Console.WriteLine("All values with first key: {0}", firstKey);
            foreach (var value in resultsByFirstKey)
            {
                Console.WriteLine(value);
            }

            // searching by second key
            var secondKey = 'c';
            var resultsBySecondKey = dictionary.Search(secondKey);
            Console.WriteLine("All values with second key: {0}", secondKey);
            foreach (var value in resultsBySecondKey)
            {
                Console.WriteLine(value);
            }

            // searching by both keys
            var resultsByBothKeys = dictionary.Search(firstKey, secondKey);
            Console.WriteLine("All values with first key {0} and second key {1}", firstKey, secondKey);
            foreach (var value in resultsByBothKeys)
            {
                Console.WriteLine(value);
            }
        }
Пример #41
0
        private static Dictionary <Type, BiDictionary <string, int> > LoadUFDictionaries()
        {
            Type[] enumTypes =
            {
                typeof(ObjectField), typeof(ItemField),       typeof(ContainerField),     typeof(UnitField),
                typeof(PlayerField), typeof(GameObjectField), typeof(DynamicObjectField),
                typeof(CorpseField), typeof(AreaTriggerField)
            };

            var dicts = new Dictionary <Type, BiDictionary <string, int> >();

            foreach (var enumType in enumTypes)
            {
                var vTypeString = string.Format("WowPacketParser.Enums.Version.{0}.{1}", GetUpdateFieldDictionaryBuildName(ClientVersion.Build), enumType.Name);
                var vEnumType   = Assembly.GetExecutingAssembly().GetType(vTypeString);
                if (vEnumType == null)
                {
                    continue;   // versions prior to 4.3.0 do not have AreaTriggerField
                }
                var vValues = Enum.GetValues(vEnumType);
                var vNames  = Enum.GetNames(vEnumType);

                var result = new BiDictionary <string, int>();

                for (var i = 0; i < vValues.Length; ++i)
                {
                    result.Add(vNames[i], (int)vValues.GetValue(i));
                }

                dicts.Add(enumType, result);
            }

            return(dicts);
        }
Пример #42
0
    static void Main()
    {
        var bidictionary = new BiDictionary <string, int, string>(allowDuplicateValues: true);

        bidictionary.Add("pesho", 1, "JavaScript");
        bidictionary.Add("gosho", 2, "Java");
        bidictionary.Add("nakov", 3, "C#");
        bidictionary.Add("nakov", 3, "C#");
        bidictionary.Add("gosho", 3, "Coffee");
        bidictionary.Add("nakov", 1, "Python");

        Console.WriteLine(string.Join(" ", bidictionary.GetByFirstKey("nakov")));
        Console.WriteLine(string.Join(" ", bidictionary.GetBySecondKey(3)));
        Console.WriteLine(string.Join(" ", bidictionary.GetByFirstAndSecondKey("nakov", 3)));

        Console.WriteLine(bidictionary.Count);

        bidictionary.RemoveByFirstKey("gosho");
        Console.WriteLine(bidictionary.Count);

        bidictionary.RemoveBySecondKey(3);
        Console.WriteLine(bidictionary.Count);

        bidictionary.RemoveByFirstAndSecondKey("nakov", 1);
        Console.WriteLine(bidictionary.Count);
    }
Пример #43
0
    static void Main()
    {
        var distances = new BiDictionary <string, string, int>();

        distances.Add("Sofia", "Varna", 443);
        distances.Add("Sofia", "Varna", 468);
        distances.Add("Sofia", "Varna", 490);
        distances.Add("Sofia", "Plovdiv", 145);
        distances.Add("Sofia", "Bourgas", 383);
        distances.Add("Plovdiv", "Bourgas", 253);
        distances.Add("Plovdiv", "Bourgas", 292);
        var distancesFromSofia      = distances.FindByKey1("Sofia");        // [443, 468, 490, 145, 383]
        var distancesToBourgas      = distances.FindByKey2("Bourgas");      // [383, 253, 292]
        var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292]
        var distancesRousseVarna    = distances.Find("Rousse", "Varna");    // []
        var distancesSofiaVarna     = distances.Find("Sofia", "Varna");     // [443, 468, 490]

        distances.Remove("Sofia", "Varna");                                 // true
        var distancesFromSofiaAgain  = distances.FindByKey1("Sofia");       // [145, 383]
        var distancesToVarna         = distances.FindByKey2("Varna");       // []
        var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna");    // []


        Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofia));
        Console.WriteLine("[{0}]", string.Join(", ", distancesToBourgas));
        Console.WriteLine("[{0}]", string.Join(", ", distancesPlovdivBourgas));
        Console.WriteLine("[{0}]", string.Join(", ", distancesRousseVarna));
        Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarna));
        Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofiaAgain));
        Console.WriteLine("[{0}]", string.Join(", ", distancesToVarna));
        Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarnaAgain));
    }
Пример #44
0
        public static void Main()
        {
            var distances = new BiDictionary<string, string, int>();
            distances.Add("Sofia", "Varna", 443);
            distances.Add("Sofia", "Varna", 468);
            distances.Add("Sofia", "Varna", 490);
            distances.Add("Sofia", "Plovdiv", 145);
            distances.Add("Sofia", "Bourgas", 383);
            distances.Add("Plovdiv", "Bourgas", 253);
            distances.Add("Plovdiv", "Bourgas", 292);
            var distancesFromSofia = distances.FindByKey1("Sofia");
            var distancesToBourgas = distances.FindByKey2("Bourgas");
            var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas");
            var distancesRousseVarna = distances.Find("Rousse", "Varna");
            var distancesSofiaVarna = distances.Find("Sofia", "Varna");
            var isDeletd = distances.Remove("Sofia", "Varna");
            var distancesFromSofiaAgain = distances.FindByKey1("Sofia");
            var distancesToVarna = distances.FindByKey2("Varna");
            var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna");

            Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofia));
            Console.WriteLine("[{0}]",string.Join(", ", distancesToBourgas));
            Console.WriteLine("[{0}]",string.Join(", ", distancesPlovdivBourgas));
            Console.WriteLine("[{0}]", string.Join(", ", distancesRousseVarna));
            Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarna));
            Console.WriteLine(isDeletd);
            Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofiaAgain));
            Console.WriteLine("[{0}]", string.Join(", ", distancesToVarna));
            Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarnaAgain));
        }
        public static void Main()
        {
            var distances = new BiDictionary <string, string, int>();

            distances.Add("Sofia", "Varna", 443);
            distances.Add("Sofia", "Varna", 468);
            distances.Add("Sofia", "Varna", 490);
            distances.Add("Sofia", "Plovdiv", 145);
            distances.Add("Sofia", "Bourgas", 383);
            distances.Add("Plovdiv", "Bourgas", 253);
            distances.Add("Plovdiv", "Bourgas", 292);

            var distancesFromSofia      = distances.FindByKey1("Sofia");        // [443, 468, 490, 145, 383]
            var distancesToBourgas      = distances.FindByKey2("Bourgas");      // [383, 253, 292]
            var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292]
            var distancesRousseVarna    = distances.Find("Rousse", "Varna");    // []
            var distancesSofiaVarna     = distances.Find("Sofia", "Varna");     // [443, 468, 490]

            distances.Remove("Sofia", "Varna");                                 // true

            var distancesFromSofiaAgain  = distances.FindByKey1("Sofia");       // [145, 383]
            var distancesToVarna         = distances.FindByKey2("Varna");       // []
            var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna");    // []

            Console.WriteLine("Use this breakpoint to debug the results :)");
        }
Пример #46
0
        private static void ConfigureContainer(
            string connectionString,
            IExecutionContextAccessor executionContextAccessor,
            ILogger logger,
            IEventsBus eventsBus)
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterModule(new LoggingModule(logger));

            var loggerFactory = new SerilogLoggerFactory(logger);

            containerBuilder.RegisterModule(new DataAccessModule(connectionString, loggerFactory));

            containerBuilder.RegisterModule(new ProcessingModule());
            containerBuilder.RegisterModule(new EventsBusModule(eventsBus));
            containerBuilder.RegisterModule(new MediatorModule());
            containerBuilder.RegisterModule(new AuthenticationModule());

            var domainNotificationsMap = new BiDictionary <string, Type>();

            domainNotificationsMap.Add("MeetingGroupProposalAcceptedNotification", typeof(MeetingGroupProposalAcceptedNotification));
            containerBuilder.RegisterModule(new OutboxModule(domainNotificationsMap));

            containerBuilder.RegisterModule(new QuartzModule());

            containerBuilder.RegisterInstance(executionContextAccessor);

            _container = containerBuilder.Build();

            AdministrationCompositionRoot.SetContainer(_container);
        }
        /// <summary>
        /// Initializes the parameters map.
        /// </summary>
        private void initializeParametersMap()
        {
            // get parameters
            this.getParamPath = new BiDictionary <FG_InputProperties, string>();
            this.getParamPath.Add(
                FG_InputProperties.Heading,
                "/instrumentation/heading-indicator/indicated-heading-deg");
            this.getParamPath.Add(FG_InputProperties.VerticalSpeed, "/instrumentation/gps/indicated-vertical-speed");
            this.getParamPath.Add(FG_InputProperties.GroundSpeed, "/instrumentation/gps/indicated-ground-speed-kt");
            this.getParamPath.Add(
                FG_InputProperties.AirSpeed,
                "/instrumentation/airspeed-indicator/indicated-speed-kt");
            this.getParamPath.Add(FG_InputProperties.GpsAltitude, "/instrumentation/gps/indicated-altitude-ft");
            this.getParamPath.Add(
                FG_InputProperties.InternalRoll,
                "/instrumentation/attitude-indicator/internal-roll-deg");
            this.getParamPath.Add(
                FG_InputProperties.InternalPitch,
                "/instrumentation/attitude-indicator/internal-pitch-deg");
            this.getParamPath.Add(
                FG_InputProperties.AltimeterAltitude,
                "/instrumentation/altimeter/indicated-altitude-ft");
            this.getParamPath.Add(FG_InputProperties.Longitude, "/position/longitude-deg");
            this.getParamPath.Add(FG_InputProperties.Latitude, "/position/latitude-deg");

            // set parameters
            this.setParamPath = new Dictionary <FG_OutputProperties, string>();
            this.setParamPath.Add(FG_OutputProperties.Throttle, "/controls/engines/current-engine/throttle ");
            this.setParamPath.Add(FG_OutputProperties.Rudder, "/controls/flight/rudder ");
            this.setParamPath.Add(FG_OutputProperties.Aileron, "/controls/flight/aileron ");
            this.setParamPath.Add(FG_OutputProperties.Elevator, "/controls/flight/elevator ");
        }
Пример #48
0
        static void Main()
        {
            var bidict = new BiDictionary<string, int, string>(allowDuplicateValues: true);

            bidict.Add("pesho", 1, "JavaScript");
            bidict.Add("gosho", 2, "Java");
            bidict.Add("nakov", 3, "C#");
            bidict.Add("nakov", 3, "C#");
            bidict.Add("gosho", 3, "Coffee");
            bidict.Add("nakov", 1, "Python");

            Console.WriteLine(string.Join(" ", bidict.GetByFirstKey("nakov")));
            Console.WriteLine(string.Join(" ", bidict.GetBySecondKey(3)));
            Console.WriteLine(string.Join(" ", bidict.GetByFirstAndSecondKey("nakov", 3)));

            Console.WriteLine(bidict.Count);

            bidict.RemoveByFirstKey("gosho");
            Console.WriteLine(bidict.Count);

            bidict.RemoveBySecondKey(3);
            Console.WriteLine(bidict.Count);

            bidict.RemoveByFirstAndSecondKey("nakov", 1);
            Console.WriteLine(bidict.Count);


        }
Пример #49
0
    static void Main()
    {
        BiDictionary <string, string, string> dictionary = new BiDictionary <string, string, string>();

        dictionary.Add("Sofia", "man", "Ivo Ivanov");
        dictionary.Add("Sofia", "woman", "Maria Ivanova");
        dictionary.Add("Plovdiv", "man", "Peter Petrov");
        dictionary.Add("Plovdiv", "woman", "Lili Georgieva");


        var fromSofia = dictionary.FindByFistKey("Sofia");

        foreach (var item in fromSofia)
        {
            Console.WriteLine(item);
        }

        var manGender = dictionary.FindBySecondKey("man");

        foreach (var item in manGender)
        {
            Console.WriteLine(item);
        }

        var manFromPlovdiv = dictionary.FindByBothKeys("Plovdiv", "man");

        foreach (var item in manFromPlovdiv)
        {
            Console.WriteLine(item);
        }
    }
Пример #50
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));
        }
Пример #51
0
 static IntentEnumExtension()
 {
     codes = new BiDictionary <IntentEnum, PdfName>();
     codes[IntentEnum.View]   = PdfName.View;
     codes[IntentEnum.Design] = PdfName.Design;
     codes[IntentEnum.All]    = PdfName.All;
 }
Пример #52
0
 public static void Main()
 {
     BiDictionary<string, string, int> myBiDictionary = new BiDictionary<string, string, int>();
     myBiDictionary.Add("Petyr", "Petrov", 30);
     Console.WriteLine(string.Join(", ", myBiDictionary.GetValueByFirstKey("Petyr")));
     Console.WriteLine(string.Join(", ", myBiDictionary.GetValueBySecondKey("Petrov")));
     Console.WriteLine(string.Join(", ", myBiDictionary.GetValueByBothKeys("Petyr", "Petrov")));
 }
Пример #53
0
 static VisibilityPolicyEnumExtension()
 {
     codes = new BiDictionary <LayerMembership.VisibilityPolicyEnum, PdfName>();
     codes[LayerMembership.VisibilityPolicyEnum.AllOn]  = PdfName.AllOn;
     codes[LayerMembership.VisibilityPolicyEnum.AnyOn]  = PdfName.AnyOn;
     codes[LayerMembership.VisibilityPolicyEnum.AnyOff] = PdfName.AnyOff;
     codes[LayerMembership.VisibilityPolicyEnum.AllOff] = PdfName.AllOff;
 }
Пример #54
0
 public SSOManager()
 {
     UserRepository     = DependencyFactory.Resolve <IRepository <UserInfo> >();
     ClientManager      = DependencyFactory.Resolve <ClientManager>();
     Tickets            = new BiDictionary <string, UserInfo>();
     AchievementManager = DependencyFactory.Resolve <AchievementManager>();
     ModerationTool     = DependencyFactory.Resolve <ModerationTool>();
 }
 static WindowTypeEnumExtension()
 {
     codes = new BiDictionary <MediaScreenParameters.Viability.WindowTypeEnum, PdfInteger>();
     codes[MediaScreenParameters.Viability.WindowTypeEnum.Floating]   = new PdfInteger(0);
     codes[MediaScreenParameters.Viability.WindowTypeEnum.FullScreen] = new PdfInteger(1);
     codes[MediaScreenParameters.Viability.WindowTypeEnum.Hidden]     = new PdfInteger(2);
     codes[MediaScreenParameters.Viability.WindowTypeEnum.Annotation] = new PdfInteger(3);
 }
Пример #56
0
 public static void Main()
 {
     BiDictionary<int, int, string> biDict = new BiDictionary<int, int, string>();
     biDict.Add(1, 1, "First");
     biDict.Add(1, 2, "Second");
     biDict.Add(2, 1, "Third");
     Console.WriteLine();
 }
Пример #57
0
 public void BiDictionaryReverseClear_Test()
 {
     var dictionary = new BiDictionary<object, object>();
     dictionary.Reverse.Add("test", "test");
     dictionary.Reverse.Add("test2", "test2");
     dictionary.Reverse.Clear();
     Assert.Empty(dictionary);
 }
Пример #58
0
        public static void InitializeOpcodeDictionary()
        {
            _serverDict = GetOpcodeDictionary(ClientVersion.Build, Direction.ServerToClient);
            _clientDict = GetOpcodeDictionary(ClientVersion.Build, Direction.ClientToServer);
            _miscDict   = GetOpcodeDictionary(ClientVersion.Build, Direction.Bidirectional);

            InitializeOpcodeNameDictionary();
        }
Пример #59
0
 public GameStateManager()
 {
     PlayerSaves = new Dictionary<string, PlayerSave>();
     PlayerEntities = new Dictionary<string, Entity>();
     Mobs = new List<Entity>();
     RUIDUsernames = new BiDictionary();
     mobFactory = new MobFactory();
 }
        public static void Main()
        {
            BiDictionary<string, string, Student> students = new BiDictionary<string, string, Student>();
            List<string> firstKeysTest = new List<string>();
            List<string> secondKeysTest = new List<string>();
            List<string> bothKeysTest = new List<string>();
            Random random = new Random();
            for (int i = 0; i < 10; i++)
            {
                var lengthFirstName = random.Next(2, 20);
                string firstName = GetRandomString(lengthFirstName, random);
                var lengthLastName = random.Next(2, 20);
                string lastName = GetRandomString(lengthLastName, random);
                Student student1 = new Student(firstName, lastName);
                students.Add(student1.FirstName, student1.LastName, student1);
                firstKeysTest.Add(student1.FirstName);
                secondKeysTest.Add(student1.LastName);
                bothKeysTest.Add(student1.FirstName + student1.LastName);
                if (i % 2 == 0)
                {
                    Student student2 = new Student(firstName, lastName);
                    students.Add(student2.FirstName, student2.LastName, student2);
                    firstKeysTest.Add(student2.FirstName);
                    secondKeysTest.Add(student2.LastName);
                    bothKeysTest.Add(student2.FirstName + student2.LastName);
                }
            }

            for (int i = 0; i < 10; i++)
            {
                var searchedFirstNameIndex = random.Next(0, firstKeysTest.Count);
                var studentsByFirstName = students.FindByFirstKey(firstKeysTest[searchedFirstNameIndex]);
                Console.WriteLine("New Search");
                Console.WriteLine("Students searched by first name:");
                foreach (var st in studentsByFirstName)
                {
                    Console.WriteLine("Student:" + st.FirstName + " " + st.LastName);
                }

                var searchedLastNameIndex = random.Next(0, secondKeysTest.Count);
                var studentsByLastName = students.FindBySecondKey(secondKeysTest[searchedLastNameIndex]);
                Console.WriteLine("Students searched by last name:");
                foreach (var st in studentsByLastName)
                {
                    Console.WriteLine("Student:" + st.FirstName + " " + st.LastName);
                }

                var studentsByBothNames = students.FindByBothKeys(firstKeysTest[i], secondKeysTest[i]);
                Console.WriteLine("Students searched by both names:");
                foreach (var st in studentsByBothNames)
                {
                    Console.WriteLine("Student: " + st.FirstName + " " + st.LastName);
                }

                Console.WriteLine();
            }
        }