From 21f4acf2d5e1b3bf82a30989cd06ea4562968ece Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 28 Apr 2024 10:26:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../MassivGenericObjects.cs | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index 4093c18..4e7950f 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -31,7 +31,7 @@ namespace HoistingCrane.CollectionGenericObjects { get { - return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth); + return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-3; } } public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects array) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs index 6538e5b..8d32f37 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs @@ -45,29 +45,35 @@ namespace HoistingCrane.CollectionGenericObjects public int Insert(T obj, int position) { - //todo Проверка позиции - if (position < 0 || position > Count) + + if (position < 0 || position >= Count) { return -1; } - if (arr[position] == null) + int copyPos = position - 1; + + while (position < Count) { - arr[position] = obj; - return position; - } - else - { - if (Insert(obj, position + 1) != -1) - { - return position; - } - if (Insert(obj, position - 1) != -1) + if (arr[position] == null) { + arr[position] = obj; return position; } + position++; } + while (copyPos > 0) + { + if (arr[copyPos] == null) + { + arr[copyPos] = obj; + return copyPos; + } + copyPos--; + } + return -1; + } public T? Remove(int position)