Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            DynamicArray <int> list = new DynamicArray <int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            list.AddRange(new int[] { 8, 8, 8, 8, 8, 8, 8 });

            list.Add(13);
            list.Add(14);

            list.Remove(5);
            list.Insert(99, 4);

            Console.WriteLine(String.Join(", ", list.ToArray()));
            Console.WriteLine(list.Length);
            Console.WriteLine(list.Capacity);

            list.SetCapasity(2);

            Console.WriteLine(list.Capacity);

            DynamicArray <int> clonedList = (DynamicArray <int>)list.Clone();

            Console.WriteLine(String.Join(", ", clonedList.ToArray()));

            CycledDynamicArray <string> cycledList = new CycledDynamicArray <string>(new string[] { "Vova", "Artem", "Daniil", "Vlad" });

            // foreach (string item in cycledList)
            // {
            //     Console.Write(item + " ");
            // }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            DynamicArray <int> dynamicArray = new DynamicArray <int>(new int[9] {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            foreach (var elem in dynamicArray)
            {
                Console.Write(elem + " ");
            }
            dynamicArray.Add(213);
            foreach (var elem in dynamicArray)
            {
                Console.Write(elem + " ");
            }
            Console.WriteLine();
            dynamicArray.AddRange(new int[9] {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            });
            foreach (var elem in dynamicArray)
            {
                Console.Write(elem + " ");
            }
            Console.WriteLine();
            dynamicArray.Add(1337);

            dynamicArray.Insert(228, 3);
            foreach (var elem in dynamicArray)
            {
                Console.Write(elem + " ");
            }
            dynamicArray[2] = 2281337;
            Console.WriteLine(dynamicArray[2]);
            foreach (var elem in dynamicArray)
            {
                Console.Write(elem + " ");
            }
            Console.WriteLine();
            CycledDynamicArray <int> arr = new CycledDynamicArray <int>();

            arr.Add(1);
            arr.Add(2);
            arr.Add(3);
            foreach (var elem in arr)
            {
                Console.WriteLine(elem);
                Thread.Sleep(500);
            }
        }
Ejemplo n.º 3
0
 public CycledArrayEnumerator(CycledDynamicArray <T> array)
 {
     this.array = array;
 }