static void Main(string[] args) { DynamicArray <int> array = new DynamicArray <int>(); Console.WriteLine(array.Length); }
static void Tests() { DynamicArray <int> test = new DynamicArray <int>(); // ======================================================= // Добавление множества элементов test.AddRange(new int[] { 7, 9, 4, 3, 2 }); // ======================================================= // Проверка Capacity при увеличении количества элементов //for (int i = 0; i < 6; i++) //{ // test.Add(i); // Console.WriteLine($"Capacity = {test.Capacity}, Length = {test.Length}"); //} // ======================================================= // Добавление ещё бОльшего количества чисел и вывод на экран //test.AddRange(new int[] { -555, 7, 9, 8, 1, 15, 26, 8, 9, 10 }); //test.PrintAll(); // ======================================================= /* Проверка ToArray() * var clonnedArr = test.ToArray(); * Console.WriteLine("====================\n====================\n===================="); * for (int i = 0; i < clonnedArr.Length; i++) * { * Console.WriteLine($"[{i}] = {clonnedArr[i]}"); * } * * for (int i = 0; i < test.Length; i++) * { * test[i] = -42; * } * Console.WriteLine("====================="); * test.PrintAll(); * * Console.WriteLine("====================\n====================\n===================="); * for (int i = 0; i < clonnedArr.Length; i++) * { * Console.WriteLine($"[{i}] = {clonnedArr[i]}"); * } */ // ======================================================= // Проверка уменьшения Capacity //for (int i = 0; i < 32; i++) //{ // test.Capacity = 32 - i; // test.PrintAll(); // Console.WriteLine("=================================="); //} //test.Capacity = 500; // ======================================================= // Удаление и вставка элементов //test.Remove(2); //test.RemoveAt(2); //test.Insert(555, 5); //test.Insert(23, 2); //test.Insert(45, 4); //test.PrintAll(); //Console.WriteLine(); // ======================================================= // Обратный и обычный индекс //for (int i = -test.Length; i < test.Length; i++) //{ // Console.WriteLine($"[{i}] = {test[i]}"); //} //Console.WriteLine(); //test.PrintAll(); }