Изменен тип возвращаемого значения для операций сложения и
вычитания
This commit is contained in:
parent
560c451cce
commit
4ca174f9f3
@ -65,7 +65,7 @@ namespace AccordionBus
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectBus bus = new(form.SelectedBus);
|
||||
if (form.SelectedBus == null || !(_mapBusesCollectionGeneric + bus))
|
||||
if (form.SelectedBus == null || (_mapBusesCollectionGeneric + bus == -1))
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
@ -92,7 +92,7 @@ namespace AccordionBus
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapBusesCollectionGeneric - pos)
|
||||
if (_mapBusesCollectionGeneric - pos != -1)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapBusesCollectionGeneric.ShowSet();
|
||||
|
@ -61,7 +61,7 @@ namespace AccordionBus
|
||||
/// <param name="map"></param>
|
||||
/// <param name="bus"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(MapWithSetBusesGeneric<T, U> map, T bus)
|
||||
public static int operator +(MapWithSetBusesGeneric<T, U> map, T bus)
|
||||
{
|
||||
return map._setBuses.Insert(bus);
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace AccordionBus
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(MapWithSetBusesGeneric<T, U> map, int position)
|
||||
public static int operator -(MapWithSetBusesGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setBuses.Remove(position);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace AccordionBus
|
||||
/// </summary>
|
||||
/// <param name="bus">Добавляемый автобус</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T bus)
|
||||
public int Insert(T bus)
|
||||
{
|
||||
return Insert(bus, 0);
|
||||
}
|
||||
@ -44,12 +44,12 @@ namespace AccordionBus
|
||||
/// <param name="bus">Добавляемый автобус</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T bus, int position)
|
||||
public int Insert(T bus, int position)
|
||||
{
|
||||
//проверка позиции
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
//поиск пустой позиции
|
||||
int positionEmpty = position;
|
||||
@ -62,7 +62,7 @@ namespace AccordionBus
|
||||
}
|
||||
if (positionEmpty == Count)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
//сдвиг вправо
|
||||
for (; positionEmpty > position; positionEmpty--)
|
||||
@ -70,21 +70,21 @@ namespace AccordionBus
|
||||
_places[positionEmpty] = _places[positionEmpty - 1];
|
||||
}
|
||||
_places[position] = bus;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
public int Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
_places[position] = null;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
|
Loading…
x
Reference in New Issue
Block a user