Lab_3_Kryukov_AI_Excavator
This commit is contained in:
parent
a75dd9c18d
commit
fddb6dc9e8
@ -26,13 +26,13 @@ namespace ProjectExcavator.Generic
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static bool operator +(ExcavatorGenericCollection<T, U> collect, T? obj)
|
||||
public static int operator +(ExcavatorGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
return collect?._collection.Insert(obj) ?? -1;
|
||||
}
|
||||
public static T? operator -(ExcavatorGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace ProjectExcavator
|
||||
{
|
||||
_places = new T?[count];
|
||||
}
|
||||
public bool Insert(T excavator)
|
||||
public int Insert(T excavator)
|
||||
{
|
||||
int i = 0;
|
||||
for (; i < _places.Length; i++)
|
||||
@ -26,18 +26,18 @@ namespace ProjectExcavator
|
||||
}
|
||||
}
|
||||
if (i == _places.Length)
|
||||
return false;
|
||||
return -1;
|
||||
for (; i > 0; i--)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[i] = excavator;
|
||||
return true;
|
||||
return Insert(excavator,0);
|
||||
}
|
||||
public bool Insert(T excavator, int position)
|
||||
public int Insert(T excavator, int position)
|
||||
{
|
||||
if (position < 0 || position >= _places.Length)
|
||||
return false;
|
||||
return -1;
|
||||
for (; position < _places.Length; position++)
|
||||
{
|
||||
if (_places[position] == null)
|
||||
@ -46,13 +46,13 @@ namespace ProjectExcavator
|
||||
}
|
||||
}
|
||||
if (position == _places.Length)
|
||||
return false;
|
||||
return -1;
|
||||
for (; position > 0; position--)
|
||||
{
|
||||
_places[position] = _places[position - 1];
|
||||
}
|
||||
_places[position] = excavator;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
public bool Remove(int position) {
|
||||
if (position >= _places.Length || position<0)
|
||||
|
Loading…
Reference in New Issue
Block a user