Done
This commit is contained in:
parent
2807485943
commit
04fb769aef
@ -9,7 +9,6 @@ namespace ProjectTrolleybus
|
|||||||
private AbstractStrategy? _strategy;
|
private AbstractStrategy? _strategy;
|
||||||
public DrawingBus? SelectedBus { get; private set; }
|
public DrawingBus? SelectedBus { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public FormTrolleybus()
|
public FormTrolleybus()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -9,39 +9,22 @@ namespace ProjectTrolleybus.Generics
|
|||||||
internal class SetGeneric<T>
|
internal class SetGeneric<T>
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Массив объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private readonly T?[] _places;
|
private readonly T?[] _places;
|
||||||
/// <summary>
|
|
||||||
/// Количество объектов в массиве
|
|
||||||
/// </summary>
|
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Length;
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
public SetGeneric(int count)
|
public SetGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T?[count];
|
_places = new T?[count];
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="trolleybus">Добавляемый автомобиль</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Insert(T trolleybus)
|
public bool Insert(T trolleybus)
|
||||||
{
|
{
|
||||||
if (_places[Count - 1] != null)
|
if (_places[Count - 1] != null)
|
||||||
return false;
|
return false;
|
||||||
return Insert(trolleybus, 0);///
|
return Insert(trolleybus, 0);///
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="trolleybus">Добавляемый автомобиль</param>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Insert(T trolleybus, int position)
|
public bool Insert(T trolleybus, int position)
|
||||||
{
|
{
|
||||||
if (!(position >= 0 && position < Count))
|
if (!(position >= 0 && position < Count))
|
||||||
@ -59,11 +42,7 @@ namespace ProjectTrolleybus.Generics
|
|||||||
_places[position] = trolleybus;
|
_places[position] = trolleybus;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
if (!(position >= 0 && position < Count) || _places[position] == null)
|
if (!(position >= 0 && position < Count) || _places[position] == null)
|
||||||
@ -71,11 +50,7 @@ namespace ProjectTrolleybus.Generics
|
|||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта из набора по позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
if (!(position >= 0 && position < Count))
|
if (!(position >= 0 && position < Count))
|
||||||
|
Loading…
Reference in New Issue
Block a user