Done++
This commit is contained in:
parent
0dade24b81
commit
be4a8c4f1d
@ -52,11 +52,11 @@ namespace ProjectTrolleybus.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static BusesGenericCollection<T, U>? operator +(BusesGenericCollection<T, U>? collect, T? obj)
|
public static int operator +(BusesGenericCollection<T, U>? collect, T? obj)
|
||||||
{
|
{
|
||||||
if (obj != null)
|
if (obj == null || collect == null)
|
||||||
collect?._collection.Insert(obj);
|
return -1;
|
||||||
return collect;
|
return collect._collection.Insert(obj);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
@ -64,14 +64,12 @@ namespace ProjectTrolleybus.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static BusesGenericCollection<T, U>? operator -(BusesGenericCollection<T, U> collect, int pos)
|
public static bool operator -(BusesGenericCollection<T, U> collect, int pos)
|
||||||
{
|
{
|
||||||
T? obj = collect._collection.Get(pos);
|
T? obj = collect?._collection.Get(pos);
|
||||||
if (obj != null)
|
if (obj == null || collect == null)
|
||||||
{
|
return false;
|
||||||
collect?._collection.Remove(pos);
|
return collect._collection.Remove(pos);
|
||||||
}
|
|
||||||
return collect;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject
|
/// Получение объекта IMoveableObject
|
||||||
|
@ -18,29 +18,29 @@ namespace ProjectTrolleybus.Generics
|
|||||||
_places = new T?[count];
|
_places = new T?[count];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T trolleybus)
|
public int Insert(T trolleybus)
|
||||||
{
|
{
|
||||||
if (_places[Count - 1] != null)
|
if (_places[Count - 1] != null)
|
||||||
return false;
|
return -1;
|
||||||
return Insert(trolleybus, 0);
|
return Insert(trolleybus, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T trolleybus, int position)
|
public int Insert(T trolleybus, int position)
|
||||||
{
|
{
|
||||||
if (!(position >= 0 && position < Count))
|
if (!(position >= 0 && position < Count))
|
||||||
return false;
|
return -1;
|
||||||
if (_places[position] != null)
|
if (_places[position] != null)
|
||||||
{
|
{
|
||||||
int ind = position;
|
int ind = position;
|
||||||
while (ind < Count && _places[ind] != null)
|
while (ind < Count && _places[ind] != null)
|
||||||
ind++;
|
ind++;
|
||||||
if (ind == Count)
|
if (ind == Count)
|
||||||
return false;
|
return -1;
|
||||||
for (int i = ind - 1; i >= position; i--)
|
for (int i = ind - 1; i >= position; i--)
|
||||||
_places[i + 1] = _places[i];
|
_places[i + 1] = _places[i];
|
||||||
}
|
}
|
||||||
_places[position] = trolleybus;
|
_places[position] = trolleybus;
|
||||||
return true;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user