public class SetGeneric { private Object[] _places; public int Count; public SetGeneric(int count) { _places = new Object[count]; Count = _places.length; } public int Insert(T ship) { // TODO вставка в начало набора int temp = 0; int k = 0; for(int j = 0; j < _places.length; j++) { if (_places[j] != null) { k++; } } if (k == _places.length) { return -1; } else { for (int i = 0; i < _places.length; i++) { if (_places[i] == null) { temp = i; break; } } for (int i = temp; i > 0; i--) { _places[i] = _places[i -1]; } _places[0] = ship; return 0; } } public boolean Insert(T ship, int position) { int temp = 0; int k = 0; for (int j = position; j < _places.length; j++) { if (_places[j] != null) { k++; } } if (position < _places.length && k < _places.length-position) { for (int i = position; i < _places.length; i++) { if (_places[i] == null) { temp = i; break; } } for (int i = temp; i > position; i--) { _places[i] = _places[i - 1]; } _places[position] = ship; return true; } else { return false; } } public boolean Remove(int position) { // TODO проверка позиции // TODO удаление объекта из массива, присвоив элементу массива //значение null if(position < _places.length) { _places[position] = null; return true; } else { return false; } } public T Get(int position) { // TODO проверка позиции if(position < _places.length) { return (T)_places[position]; } else { return null; } } }