небольшие изменения
This commit is contained in:
parent
7d86b06bea
commit
517c33d45d
@ -27,13 +27,15 @@ namespace ProjectLainer.Generics
|
|||||||
if (obj != null && collect != null)
|
if (obj != null && collect != null)
|
||||||
{
|
{
|
||||||
DrawiningLainerEqutables equal = new Generics.DrawiningLainerEqutables();
|
DrawiningLainerEqutables equal = new Generics.DrawiningLainerEqutables();
|
||||||
return collect._collection.Insert(obj, equal);
|
collect._collection.Insert(obj, equal);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public static bool operator -(LainersGenericCollection<T, U> collect, int pos)
|
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)
|
public U? GetU(int pos)
|
||||||
{
|
{
|
||||||
|
@ -16,22 +16,21 @@ namespace ProjectLainer.Generics
|
|||||||
_places = new List<T?>(count);
|
_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)
|
if (_places.Count == _maxCount)
|
||||||
{
|
{
|
||||||
throw new OverflowException();
|
throw new StorageOverflowException(_maxCount);
|
||||||
}
|
}
|
||||||
Insert(lainer, 0, equal);
|
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))
|
if (!(position >= 0 && position <= Count))
|
||||||
{
|
{
|
||||||
return false;
|
throw new Exception("Неверная позиция для вставки");
|
||||||
}
|
}
|
||||||
if (equal != null)
|
if (equal != null)
|
||||||
{
|
{
|
||||||
@ -44,25 +43,19 @@ namespace ProjectLainer.Generics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_places.Insert(position, lainer);
|
_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);
|
_places.RemoveAt(position);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new LainerNotFoundException();
|
throw new LainerNotFoundException(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public T? this[int position]
|
public T? this[int position]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
Loading…
Reference in New Issue
Block a user