Изменил(а) на 'ProjectPlane/ProjectPlane/SetPlanesGeneric.cs'

This commit is contained in:
devil_1nc 2022-12-09 16:46:27 +04:00
parent c920e6c1d5
commit 0b5fb3ff3d

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ProjectPlane
{
internal class SetPlanesGeneric<T> where T : class
internal class SetPlanesGeneric<T> where T : class, IEquatable<T>
{
/// <summary>
/// Список объектов, которые храним
@ -43,12 +43,11 @@ namespace ProjectPlane
/// <returns></returns>
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;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
@ -102,5 +101,14 @@ namespace ProjectPlane
}
}
}
public void SortSet(IComparer<T> comparer)
{
if (comparer == null)
{
return;
}
_places.Sort(comparer);
}
}
}