PIBD-12_Morozov_D.V. LabWork№4 #13

Closed
MorozovDanil wants to merge 15 commits from Lab4_base into Lab3_base
Showing only changes of commit 9d782d7465 - Show all commits

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;
}
}