From 0b5fb3ff3d5bf624d5393bdcc15b76c0a461fa8f Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Fri, 9 Dec 2022 16:46:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'ProjectPlane/ProjectPlane/SetPlanesGe?= =?UTF-8?q?neric.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectPlane/ProjectPlane/SetPlanesGeneric.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ProjectPlane/ProjectPlane/SetPlanesGeneric.cs b/ProjectPlane/ProjectPlane/SetPlanesGeneric.cs index ef15c44..3212255 100644 --- a/ProjectPlane/ProjectPlane/SetPlanesGeneric.cs +++ b/ProjectPlane/ProjectPlane/SetPlanesGeneric.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ProjectPlane { - internal class SetPlanesGeneric where T : class + internal class SetPlanesGeneric where T : class, IEquatable { /// /// Список объектов, которые храним @@ -43,12 +43,11 @@ namespace ProjectPlane /// public int Insert(T plane, int position) { - if (Count == _maxCount) throw new StorageOverflowException(_maxCount); + if (_places.Contains(plane)) return -1; - if (position < 0 || position >= _maxCount) return -1; + if (position < 0 || position >= _maxCount) throw new StorageOverflowException(_maxCount); _places.Insert(position, plane); return position; - } /// /// Удаление объекта из набора с конкретной позиции @@ -102,5 +101,14 @@ namespace ProjectPlane } } } + public void SortSet(IComparer comparer) + { + if (comparer == null) + { + return; + } + _places.Sort(comparer); + } + } }