небольшие изменения

This commit is contained in:
Ivan_Starostin 2023-12-22 19:44:52 +04:00
parent 7d86b06bea
commit 517c33d45d
2 changed files with 15 additions and 20 deletions

View File

@ -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<T, U> collect, int pos)
{
return collect._collection.Remove(pos);
collect._collection.Remove(pos);
return true;
}
public U? GetU(int pos)
{

View File

@ -16,22 +16,21 @@ namespace ProjectLainer.Generics
_places = new List<T?>(count);
}
public bool Insert(T lainer, IEqualityComparer<T?>? equal = null)
public void Insert(T lainer, IEqualityComparer<T?>? 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<T?>? equal = null)
public void Insert(T lainer, int position, IEqualityComparer<T?>? 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]
{