From 68f321a652cb817ba6ebd979bcf76b61845ab50f Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:24:18 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MassivGenericObjects.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs index ef399d3..39d6839 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs @@ -8,39 +8,39 @@ namespace HoistingCrane.CollectionGenericObjects { arr = Array.Empty(); } - public int Count + public int Count { - get { return arr.Length; } - } + get { return arr.Length; } + } public int SetMaxCount { set { if (value > 0) { - arr = new T?[value]; + if (arr.Length > 0) + { + Array.Resize(ref arr, value); + } + else + { + arr = new T?[value]; + } } } } public T? Get(int position) { - if(position >= 0 && position < arr.Length) + if (position >= 0 && position < arr.Length) { return arr[position]; } - return null; + return null; } public int Insert(T obj) { - for (int i = 0; i < Count; i++) - { - if (arr[i] == null) - { - return Insert(obj, 0); - } - } - return -1; + return Insert(obj, 0); } public int Insert(T obj, int position)