full 8
This commit is contained in:
parent
4d6bd4e5ae
commit
39170916b9
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Catamaran
|
namespace Catamaran
|
||||||
{
|
{
|
||||||
internal abstract class AbstractMap
|
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||||
{
|
{
|
||||||
private IDrawingObject _drawingObject = null;
|
private IDrawingObject _drawingObject = null;
|
||||||
protected int[,] _map = null;
|
protected int[,] _map = null;
|
||||||
@ -160,5 +160,31 @@ namespace Catamaran
|
|||||||
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
protected abstract void DrawRoadPart(Graphics g, int i, int j);
|
||||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public bool Equals(AbstractMap other)
|
||||||
|
{
|
||||||
|
if (other == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var thisMap = this;
|
||||||
|
var otherMap = other;
|
||||||
|
|
||||||
|
if (thisMap._width != otherMap._width) return false;
|
||||||
|
if (thisMap._height != otherMap._height) return false;
|
||||||
|
if (thisMap._size_x != otherMap._size_x) return false;
|
||||||
|
if (thisMap._size_y != otherMap._size_y) return false;
|
||||||
|
if (thisMap._map.GetLength(0) != otherMap._map.GetLength(0) || thisMap._map.GetLength(1) != otherMap._map.GetLength(1)) return false;
|
||||||
|
for (int i = 0; i < thisMap._map.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < thisMap._map.GetLength(1); j++)
|
||||||
|
{
|
||||||
|
if (thisMap._map[i, j] != otherMap._map[i, j]) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Catamaran
|
|||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <typeparam name="U"></typeparam>
|
/// <typeparam name="U"></typeparam>
|
||||||
internal class MapWithSetBoatsGeneric<T, U>
|
internal class MapWithSetBoatsGeneric<T, U>
|
||||||
where T : class, IDrawingObject
|
where T : class, IDrawingObject, IEquatable<T>
|
||||||
where U : AbstractMap
|
where U : AbstractMap
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -214,7 +214,7 @@ namespace Catamaran
|
|||||||
/// <param name="comparer"></param>
|
/// <param name="comparer"></param>
|
||||||
public void Sort(IComparer<T> comparer)
|
public void Sort(IComparer<T> comparer)
|
||||||
{
|
{
|
||||||
_setCars.SortSet(comparer);
|
_setBoats.SortSet(comparer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,17 @@ namespace Catamaran
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T boat)
|
public int Insert(T boat)
|
||||||
{
|
{
|
||||||
|
if (_places.Contains(boat)) return -1 ;
|
||||||
|
for (int i = 0; i < _maxCount; i++)
|
||||||
|
{
|
||||||
|
if (i == Count)
|
||||||
|
{
|
||||||
|
_places.Insert(i, boat);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new StorageOverflowException(_maxCount);
|
||||||
|
|
||||||
return Insert(boat, 0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
@ -52,7 +60,7 @@ namespace Catamaran
|
|||||||
public int Insert(T boat, int position)
|
public int Insert(T boat, int position)
|
||||||
{
|
{
|
||||||
// TODO проверка на уникальность
|
// TODO проверка на уникальность
|
||||||
|
|
||||||
// проверка позиции
|
// проверка позиции
|
||||||
if (position < 0 || position >= _maxCount)
|
if (position < 0 || position >= _maxCount)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user