типы поправил

This commit is contained in:
MorozovDanil 2024-04-15 01:48:53 +04:00
parent 40042fbcef
commit 9d782d7465

View File

@ -50,21 +50,21 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return null;
}
public bool Insert(T obj)
public int Insert(T obj)
{
return Insert(obj, 0);
}
public bool Insert(T obj, int position)
public int Insert(T obj, int position)
{
if (position < 0 || position >= Count)
{
return false;
return -1;
}
if (_collection[position] == null)
{
_collection[position] = obj;
return true;
return position;
}
for (int i = position + 1; i < Count; i++)
@ -72,7 +72,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
if (_collection[i] == null)
{
_collection[i] = obj;
return true;
return i;
}
}
for (int i = position - 1; i >= 0; i--)
@ -80,21 +80,21 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
if (_collection[i] == null)
{
_collection[i] = obj;
return true;
return i;
}
}
return false;
return -1;
}
public bool Remove(int position)
public T Remove(int position)
{
if (position < 0 || position >= Count)
{
return false;
return null;
}
T obj = _collection[position];
_collection[position] = null;
return true;
return obj;
}
}