Created FlexArrayStringTests.cs and added the necessary fields and constructor
This commit is contained in:
parent
d6c814766d
commit
7e70235831
2 changed files with 30 additions and 0 deletions
6
FlexArray.Test/FlexArrayStringTests.cs
Normal file
6
FlexArray.Test/FlexArrayStringTests.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace FlexArray.Test;
|
||||||
|
|
||||||
|
public class FlexArrayStringTests
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,5 +2,29 @@
|
||||||
|
|
||||||
public class FlexArrayString
|
public class FlexArrayString
|
||||||
{
|
{
|
||||||
|
public const int DefaultStartSize = 4;
|
||||||
|
private string[] _data;
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
public int Capacity => _data.Length;
|
||||||
|
|
||||||
|
public string this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (index < 0 || index > Count)
|
||||||
|
{
|
||||||
|
// To make the other people feel miserable :)
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _data[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlexArrayString(int? initialSize = null)
|
||||||
|
{
|
||||||
|
var size = Math.Max(0, initialSize ?? DefaultStartSize);
|
||||||
|
_data = new string[size];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue