From 517c33d45d137ec8cdcdbffa678b06194c85e967 Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Fri, 22 Dec 2023 19:44:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lainer/Lainer1/LainerGenericCollection.cs | 6 +++-- lainer/Lainer1/SetGeneric.cs | 29 +++++++++-------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lainer/Lainer1/LainerGenericCollection.cs b/lainer/Lainer1/LainerGenericCollection.cs index 5c524e6..4b7fc6d 100644 --- a/lainer/Lainer1/LainerGenericCollection.cs +++ b/lainer/Lainer1/LainerGenericCollection.cs @@ -27,13 +27,15 @@ namespace ProjectLainer.Generics if (obj != null && collect != null) { DrawiningLainerEqutables equal = new Generics.DrawiningLainerEqutables(); - return collect._collection.Insert(obj, equal); + collect._collection.Insert(obj, equal); + return true; } return false; } public static bool operator -(LainersGenericCollection collect, int pos) { - return collect._collection.Remove(pos); + collect._collection.Remove(pos); + return true; } public U? GetU(int pos) { diff --git a/lainer/Lainer1/SetGeneric.cs b/lainer/Lainer1/SetGeneric.cs index fa4b797..2e7a2b6 100644 --- a/lainer/Lainer1/SetGeneric.cs +++ b/lainer/Lainer1/SetGeneric.cs @@ -16,22 +16,21 @@ namespace ProjectLainer.Generics _places = new List(count); } - public bool Insert(T lainer, IEqualityComparer? equal = null) + public void Insert(T lainer, IEqualityComparer? equal = null) { if (_places.Count == _maxCount) { - throw new OverflowException(); + throw new StorageOverflowException(_maxCount); } Insert(lainer, 0, equal); - return true; } - public bool Insert(T lainer, int position, IEqualityComparer? equal = null) + public void Insert(T lainer, int position, IEqualityComparer? equal = null) { // объект есть уже в коллекции - выбросить исключение if (!(position >= 0 && position <= Count)) { - return false; + throw new Exception("Неверная позиция для вставки"); } if (equal != null) { @@ -44,24 +43,18 @@ namespace ProjectLainer.Generics } } _places.Insert(position, lainer); - return true; } - public bool Remove(int position) + public void Remove(int position) { - if(position < _maxCount && position >= 0) + if (position < Count && position >= 0) { - if(position < Count) - { - _places.RemoveAt(position); - return true; - } - else - { - throw new LainerNotFoundException(); - } + _places.RemoveAt(position); + } + else + { + throw new LainerNotFoundException(position); } - return false; } public T? this[int position] {