public static void ShowHM()
        {
            var    mas = new List <int>();
            Random r   = new Random();

            for (int i = 0; i < 9; i++)
            {
                mas.Add(r.Next(100));
            }
            Console.WriteLine("Dynamic Array Hardcore Mode:");
            var res = new DynamicArrayHardcoreMode <int>(mas, mas.Count);

            Console.WriteLine($"Length: {res.Length}\nCapacity: {res.Capacity}");
            Console.WriteLine("New Array:");
            foreach (var item in res)
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine();

            Console.WriteLine("Last element");
            Console.WriteLine(res[-1]);

            //res.NewCapacity(12);
            Console.WriteLine();
            Console.WriteLine();
        }
        public object Clone()
        {
            var temp = new DynamicArrayHardcoreMode <T>(Capacity);

            temp.AddRange(Array, Length);
            temp.Length = Length;
            return(temp);
        }
예제 #3
0
        static void Main()
        {
            double selection;

            do
            {
                Console.WriteLine("3,1 LOST.");
                Console.WriteLine("3,2 WORD FREQUENCY.");
                Console.WriteLine("3,3 DYNAMIC ARRAY AND HARDCORE MODE.");
                Console.WriteLine("3,4 CYCLED ARRAY.");
                Console.WriteLine("0 Exit.");
                Console.WriteLine();
                if (double.TryParse(Console.ReadLine(), out selection))
                {
                    switch (selection)
                    {
                    case 3.1:
                        Lost.Read();
                        break;

                    case 3.2:
                        var txt = WordFrequency.Read();
                        Dictionary <string, int> result = WordFrequency.WordFrequence(txt);
                        WordFrequency.Show(result);
                        break;

                    case 3.3:

                        DynamicArray <int> .Show();

                        Console.WriteLine();
                        DynamicArrayHardcoreMode <int> .ShowHM();

                        break;

                    case 3.4:
                        var vs = new CycledDynamicArray <int>(new List <int> {
                            1, 2, 3, 4, 5
                        }, 5);
                        foreach (var item in vs)
                        {
                            Console.WriteLine(item);
                        }
                        break;

                    case 0:
                        break;
                    }
                }
            } while (selection != 0);
        }