Made Add function, Added Tests. Added comments to int Tests

This commit is contained in:
MarcUs7i 2024-11-27 17:24:42 +01:00
parent aad560b4fc
commit a032e495cf
3 changed files with 71 additions and 1 deletions

View file

@ -27,4 +27,21 @@ public class FlexArrayString
var size = Math.Max(0, initialSize ?? DefaultStartSize);
_data = new string[size];
}
public void Add(string input)
{
if (Capacity == Count)
{
Grow();
}
_data[Count++] = input;
}
private void Grow()
{
var newData = new string[Capacity * 2];
Array.Copy(_data, newData, Count);
_data = newData;
}
}