мяу
This commit is contained in:
parent
daf02bad9d
commit
9a22658047
@ -72,14 +72,9 @@ public abstract class AbstractCompany
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="position">Номер удаляемого объекта</param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(AbstractCompany company, int pos)
|
||||
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||
{
|
||||
DrawningTrackedVehicle? obj = company._collection.Get(pos);
|
||||
if (obj != null)
|
||||
{
|
||||
company._collection.Remove(pos);
|
||||
}
|
||||
return false;
|
||||
return company._collection?.Remove(position) ?? null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение случайного объекта из коллекции
|
||||
|
@ -37,7 +37,7 @@ public interface ICollectionGenericObjects<T>
|
||||
/// </summary>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
||||
bool Remove(int position);
|
||||
T? Remove(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта по позиции
|
||||
|
@ -49,12 +49,12 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return 1;
|
||||
}
|
||||
|
||||
public bool Remove(int position)
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
return false;
|
||||
if (position < 0 || position > Count) return null;
|
||||
T? pos = _collection[position];
|
||||
_collection.RemoveAt(position);
|
||||
return true;
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,15 +78,16 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
return position;
|
||||
}
|
||||
|
||||
public bool Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
T drawningTrackedVehicle = _collection[position];
|
||||
_collection[position] = null;
|
||||
|
||||
|
||||
return true;
|
||||
return drawningTrackedVehicle;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user