Изменены типы возвращаемых значений
This commit is contained in:
parent
66371369da
commit
c1dbdd80ed
@ -52,7 +52,7 @@ namespace Artilleries
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawingObjectArtillery car = new(form.SelectedArtillery);
|
||||
if (_mapArtilleriesCollectionGeneric + car)
|
||||
if (_mapArtilleriesCollectionGeneric + car != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
|
||||
@ -75,7 +75,7 @@ namespace Artilleries
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapArtilleriesCollectionGeneric - pos)
|
||||
if (_mapArtilleriesCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
|
||||
|
@ -27,14 +27,14 @@ namespace Artilleries
|
||||
_map = map;
|
||||
}
|
||||
|
||||
public static bool operator +(MapWithSetArtilleriesGeneric<T, U> map, T artillery)
|
||||
public static int operator +(MapWithSetArtilleriesGeneric<T, U> map, T artillery)
|
||||
{
|
||||
return map._setArtilleries.Insert(artillery); // TODO
|
||||
return map._setArtilleries.Insert(artillery);
|
||||
}
|
||||
|
||||
public static bool operator -(MapWithSetArtilleriesGeneric<T, U> map, int position)
|
||||
public static T operator -(MapWithSetArtilleriesGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setArtilleries.Remove(position); // TODO
|
||||
return map._setArtilleries.Remove(position);
|
||||
}
|
||||
|
||||
public Bitmap ShowSet()
|
||||
|
@ -17,22 +17,22 @@ namespace Artilleries
|
||||
_places = new T[count];
|
||||
}
|
||||
|
||||
public bool Insert(T artillery)
|
||||
public int Insert(T artillery)
|
||||
{
|
||||
return Insert(artillery, 0);
|
||||
}
|
||||
|
||||
public bool Insert(T artillery, int position)
|
||||
public int Insert(T artillery, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_places[position] == null)
|
||||
{
|
||||
_places[position] = artillery;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
|
||||
int firstNull = -1;
|
||||
@ -48,27 +48,29 @@ namespace Artilleries
|
||||
|
||||
if (firstNull == -1)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = firstNull; i > position; i--)
|
||||
{
|
||||
(_places[i], _places[i - 1]) = (_places[i - 1], _places[i]);
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
|
||||
_places[position] = artillery;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
|
||||
public bool Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count || _places[position] == null)
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = _places[position];
|
||||
|
||||
_places[position] = null;
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
public T Get(int position)
|
||||
|
Loading…
Reference in New Issue
Block a user