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] {