Esempio n. 1
0
        public static void SortedDictionaryTestingTValue(SteamBoat ship, int position)
        {
            Console.WriteLine("//////////|||||\\\\\\\\\\");
            Stopwatch stopwatch1_1 = new Stopwatch();

            stopwatch1_1.Start();
            collections.SortedDictionaryShip.ContainsValue(collections.SortedDictionaryShip.First().Value);
            stopwatch1_1.Stop();
            Console.WriteLine($"Метод ContainsValue нашёл первый элемент для коллекции 2 со значением <TValue> за {stopwatch1_1.ElapsedTicks}  тиков.");
            Stopwatch stopwatch2_1 = new Stopwatch();

            stopwatch2_1.Start();
            collections.SortedDictionaryShip.ContainsValue(collections.SortedDictionaryShip.ElementAt(position).Value);
            stopwatch2_1.Stop();
            Console.WriteLine($"Метод ContainsValue нашёл элемент в середине для коллекции 2 со значением <TValue> за {stopwatch2_1.ElapsedTicks} тиков.");
            Stopwatch stopwatch3_1 = new Stopwatch();

            stopwatch3_1.Start();
            collections.SortedDictionaryShip.ContainsValue(collections.SortedDictionaryShip.ElementAt(collections.Size - 1).Value);
            stopwatch3_1.Stop();
            Console.WriteLine($"Метод Containsvalue нашёл последний элемент для коллекции 2 со значением <TValue> за {stopwatch3_1.ElapsedTicks} тиков.");
            Stopwatch stopwatch4_1 = new Stopwatch();

            stopwatch4_1.Start();
            collections.SortedDictionaryShip.ContainsValue(ship);
            stopwatch4_1.Stop();
            Console.WriteLine($"Метод ContainsValue, не найдя элемент, прошёл коллекцию 2 со значением <TValue> за {stopwatch4_1.ElapsedTicks} тиков.");
            Console.WriteLine("\\\\\\\\\\|||||//////////");
        }
Esempio n. 2
0
        public static Ship CreateElement()
        {
            int  classofShip = random.Next(1, 4);
            Ship ship        = new Ship();

            switch (classofShip)
            {
            case 1:
            {
                ship = new SteamBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                break;
            }

            case 2:
            {
                ship = new SailBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                break;
            }

            case 3:
            {
                ship = new Corvette(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                break;
            }
            }
            return(ship);
        }
Esempio n. 3
0
        public static List <Ship> GenListShipCollection(int size)
        {
            List <Ship> shipList = new List <Ship>();

            for (int i = 0; i < size; i++)
            {
                int classofShip = random.Next(1, 4);
                switch (classofShip)
                {
                case 1:
                {
                    SteamBoat ship = new SteamBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                    shipList.Add(ship);
                    break;
                }

                case 2:
                {
                    SailBoat ship = new SailBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                    shipList.Add(ship);
                    break;
                }

                case 3:
                {
                    Corvette ship = new Corvette(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                    shipList.Add(ship);
                    break;
                }
                }
            }
            return(shipList);
        }
Esempio n. 4
0
        public static Stack GenStackShipCollection(int size)
        {
            Stack shipStack = new Stack();

            for (int i = 0; i < size; i++)
            {
                int classofShip = random.Next(1, 4);
                switch (classofShip)
                {
                case 1:
                {
                    SteamBoat ship = new SteamBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                    shipStack.Push(ship);
                    break;
                }

                case 2:
                {
                    SailBoat ship = new SailBoat(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                    shipStack.Push(ship);
                    break;
                }

                case 3:
                {
                    Corvette ship = new Corvette(ShipName[random.Next(0, ShipName.Length)] + ShipNamePostfix[random.Next(0, ShipNamePostfix.Length)], random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), PortName[random.Next(0, PortName.Length)], random.Next(800, 1600));
                    shipStack.Push(ship);
                    break;
                }
                }
            }
            return(shipStack);
        }
Esempio n. 5
0
        public static void TimeTesting()
        {
            int       MiddleElement        = random.Next(1, collections.Size - 1);
            SteamBoat OutofRangeElement    = new SteamBoat("Лучезарный IV", random.Next(1950, 2020), random.Next(50, 140), random.Next(10, 100), "Архангельск", random.Next(800, 1600));
            Ship      OutofRangeElementKey = OutofRangeElement.GetBaseShip;

            QueueTesting(OutofRangeElementKey, MiddleElement);
            SortedDictionaryTestingTKey(OutofRangeElementKey, MiddleElement);
            SortedDictionaryTestingTValue(OutofRangeElement, MiddleElement);
        }