[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()));
                }
            }
        }
Пример #2
0
    public static void Main()
    {
        BiDictionary<string, int, string> biDictionary = new BiDictionary<string, int, string>();

        biDictionary.Add("first", 1, "Superman");
        biDictionary.Add("second", 2, "Batman");
        biDictionary.Add("third", 1, "Cat woman");
        biDictionary.Add("first", 3, "Joker");
        biDictionary.Add("second", 2, "Boyko Borisov");
        biDictionary.Add("first", 1, "Hawk woman");

        Console.WriteLine("Get records by key1 = 'first':");
        var allFirst = biDictionary.Get("first");

        foreach (var superhero in allFirst)
        {
            Console.WriteLine(superhero);
        }
        Console.WriteLine();

        Console.WriteLine("Get records by key2 = 1:");
        var allOne = biDictionary.Get(1);

        foreach (var superhero in allOne)
        {
            Console.WriteLine(superhero);
        }
        Console.WriteLine();

        Console.WriteLine("Get records bykey1 = 'first' and key2 = 1:");
        var allFirstOne = biDictionary.Get("first", 1);

        foreach (var superhero in allFirstOne)
        {
            Console.WriteLine(superhero);
        }
        Console.WriteLine();
    }
        [Test()]        //, Repeat(2)]
        public void AddRemoveAllAdd()
        {
            var Random  = Initialise();
            var Records = new BiDictionary <int, int>();

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

            while (Records.Count > 0)
            {
                var Key = Records.Get(Random.Next(0, Records.Count)).Key;

                Records.Remove(Key);
            }

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