From 4b22945de35f43da64b13e5ac1ec8711cc9d122c Mon Sep 17 00:00:00 2001 From: mar-va Date: Wed, 3 Apr 2024 12:37:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=964?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ListGenericObjects.cs | 11 +++++++--- .../MassiveGenericObjects.cs | 21 +++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs index 8aa1313..1eb13ec 100644 --- a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs @@ -14,11 +14,16 @@ public class ListGenericObjects : ICollectionGenericObjects private int _maxCount; public int MaxCount => _maxCount; - public int Count => throw new NotImplementedException(); + public int Count => _collection.Count; - public int SetMaxCount { set => throw new NotImplementedException(); } + public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } - public T? Get(int position) + public ListGenericObjects() + { + _collection = new(); + } + + public T Get(int position) { if (position < 0 || position >= _collection.Count || _collection == null || _collection.Count == 0) return null; diff --git a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs index f116585..2694786 100644 --- a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs @@ -20,7 +20,24 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Count => _collection.Length; - public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } + public int SetMaxCount + { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } + /// /// Конструктор @@ -96,7 +113,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects { return null; } - T temp = _collection[position]; + T? temp = _collection[position]; _collection[position] = null; return temp; }