diff --git a/Trolleybus/Trolleybus/BusesGenericCollection.cs b/Trolleybus/Trolleybus/BusesGenericCollection.cs
index 3de065c..08dcc19 100644
--- a/Trolleybus/Trolleybus/BusesGenericCollection.cs
+++ b/Trolleybus/Trolleybus/BusesGenericCollection.cs
@@ -52,11 +52,11 @@ namespace ProjectTrolleybus.Generics
///
///
///
- public static BusesGenericCollection? operator +(BusesGenericCollection? collect, T? obj)
+ public static int operator +(BusesGenericCollection? collect, T? obj)
{
- if (obj != null)
- collect?._collection.Insert(obj);
- return collect;
+ if (obj == null || collect == null)
+ return -1;
+ return collect._collection.Insert(obj);
}
///
/// Перегрузка оператора вычитания
@@ -64,14 +64,12 @@ namespace ProjectTrolleybus.Generics
///
///
///
- public static BusesGenericCollection? operator -(BusesGenericCollection collect, int pos)
+ public static bool operator -(BusesGenericCollection collect, int pos)
{
- T? obj = collect._collection.Get(pos);
- if (obj != null)
- {
- collect?._collection.Remove(pos);
- }
- return collect;
+ T? obj = collect?._collection.Get(pos);
+ if (obj == null || collect == null)
+ return false;
+ return collect._collection.Remove(pos);
}
///
/// Получение объекта IMoveableObject
diff --git a/Trolleybus/Trolleybus/SetGeneric.cs b/Trolleybus/Trolleybus/SetGeneric.cs
index 1b9dd9c..eff0865 100644
--- a/Trolleybus/Trolleybus/SetGeneric.cs
+++ b/Trolleybus/Trolleybus/SetGeneric.cs
@@ -18,29 +18,29 @@ namespace ProjectTrolleybus.Generics
_places = new T?[count];
}
- public bool Insert(T trolleybus)
+ public int Insert(T trolleybus)
{
if (_places[Count - 1] != null)
- return false;
+ return -1;
return Insert(trolleybus, 0);
}
- public bool Insert(T trolleybus, int position)
+ public int Insert(T trolleybus, int position)
{
if (!(position >= 0 && position < Count))
- return false;
+ return -1;
if (_places[position] != null)
{
int ind = position;
while (ind < Count && _places[ind] != null)
ind++;
if (ind == Count)
- return false;
+ return -1;
for (int i = ind - 1; i >= position; i--)
_places[i + 1] = _places[i];
}
_places[position] = trolleybus;
- return true;
+ return position;
}
public bool Remove(int position)