From 98421f8d63217e0c6e74183d1dcf33ff7cf6872c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BE=D0=BB=D0=BE=D0=B4=D1=8F?= Date: Fri, 11 Nov 2022 11:05:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D0=B2=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=D0=B5=20SetPlaneGeneric?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs b/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs index 45b9dc2..291aa24 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs @@ -20,17 +20,13 @@ namespace AirPlaneWithRadar } public int Insert(T plain) { - if (_places.Count == _maxCount) - { - return -1; - } - _places.Insert(0, plain); - + + Insert(plain, 0); return _places.Count; } public int Insert(T plain, int position) { - if (position < 0 || _places.Count < position||position > _maxCount) + if (position < 0 || _places.Count < position||position > _maxCount || _places.Count == _maxCount) return -1; else if (plain == null) return -1;