Исправления в generic-классах
This commit is contained in:
parent
018364f793
commit
468e737fda
@ -25,14 +25,14 @@ public class MapWithSetArmoredCarsGeneric<T extends IDrawingObject, U extends Ab
|
||||
_map = map;
|
||||
}
|
||||
|
||||
public int add(MapWithSetArmoredCarsGeneric<T, U> map, T car)
|
||||
public int add(T car)
|
||||
{
|
||||
return map._setCars.Insert(car);
|
||||
return _setCars.Insert(car);
|
||||
}
|
||||
|
||||
public T remove(MapWithSetArmoredCarsGeneric<T, U> map, int position)
|
||||
public T remove(int position)
|
||||
{
|
||||
return map._setCars.Remove(position);
|
||||
return _setCars.Remove(position);
|
||||
}
|
||||
|
||||
public Image ShowSet()
|
||||
|
@ -3,27 +3,22 @@ import java.util.ArrayList;
|
||||
|
||||
public class SetArmoredCarsGeneric<T> {
|
||||
private T[] _places;
|
||||
public int Count = _places.length;
|
||||
public int Count = getCount();
|
||||
|
||||
public SetArmoredCarsGeneric(int count)
|
||||
{
|
||||
_places = (T[]) new Object[count];
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="armoredCar">Добавляемый автомобиль</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public int getCount() {
|
||||
return _places != null ? _places.length : 0;
|
||||
}
|
||||
|
||||
public int Insert(T armoredCar)
|
||||
{
|
||||
return Insert(armoredCar, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="armoredCar">Добавляемый автомобиль</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public int Insert(T armoredCar, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
@ -53,11 +48,7 @@ public class SetArmoredCarsGeneric<T> {
|
||||
_places[position] = armoredCar;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
@ -66,11 +57,7 @@ public class SetArmoredCarsGeneric<T> {
|
||||
_places[position] = null;
|
||||
return armoredCar;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public T Get(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
|
Loading…
x
Reference in New Issue
Block a user