diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs
index efe2f6c..b61f003 100644
--- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs
+++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs
@@ -57,8 +57,8 @@ namespace AirBomber
///
///
///
- ///
- public static bool operator +(MapWithSetAirplanesGeneric map, T airplane)
+ /// Возвращает позицию вставленого объекта либо -1, если не получилось его добавить
+ public static int operator +(MapWithSetAirplanesGeneric map, T airplane)
{
return map._setAirplanes.Insert(airplane);
}
@@ -67,8 +67,8 @@ namespace AirBomber
///
///
///
- ///
- public static bool operator -(MapWithSetAirplanesGeneric map, int position)
+ /// Возвращает удаленный объект, либо null если его не удалось удалить
+ public static T operator -(MapWithSetAirplanesGeneric map, int position)
{
return map._setAirplanes.Remove(position);
}
diff --git a/AirBomber/AirBomber/SetAirplanesGeneric.cs b/AirBomber/AirBomber/SetAirplanesGeneric.cs
index 178d798..5b17243 100644
--- a/AirBomber/AirBomber/SetAirplanesGeneric.cs
+++ b/AirBomber/AirBomber/SetAirplanesGeneric.cs
@@ -33,8 +33,8 @@ namespace AirBomber
/// Добавление объекта в набор
///
/// Добавляемый самолет
- ///
- public bool Insert(T airplane)
+ /// Возвращает позицию вставленого объекта либо -1, если не получилось его добавить
+ public int Insert(T airplane)
{
return Insert(airplane, 0);
}
@@ -48,8 +48,8 @@ namespace AirBomber
///
/// Добавляемый самолет
/// Позиция
- ///
- public bool Insert(T airplane, int position)
+ /// Возвращает позицию вставленого объекта либо -1, если не получилось его добавить
+ public int Insert(T airplane, int position)
{
int positionNullElement = position;
while (Get(positionNullElement) != null)
@@ -59,7 +59,7 @@ namespace AirBomber
// Если изначальная позиция была некорректной или пустых элементов справа не оказалось возвращаем false
if (!isCorrectPosition(positionNullElement))
{
- return false;
+ return -1;
}
while (positionNullElement != position) // Смещение вправо
{
@@ -67,19 +67,20 @@ namespace AirBomber
positionNullElement--;
}
_places[position] = airplane;
- return true;
+ return position;
}
///
/// Удаление объекта из набора с конкретной позиции
///
///
- ///
- public bool Remove(int position)
+ /// Возвращает удаленный объект, либо null если его не удалось удалить
+ public T Remove(int position)
{
if (!isCorrectPosition(position))
- return false;
+ return null;
+ var result = _places[position];
_places[position] = null;
- return true;
+ return result;
}
///
/// Получение объекта из набора по позиции