A library for operations on value type data. The main task is to limit the allocation of data on Heap.
dotnet add package BanishedDev.Libs.Data --version 0.1.0-dev.22301201
DataCollection<T> where T: unmanaged
var intCollection = new DataCollection<int>(5);
var dateTimeCollection = new DataCollection<DateTime>(10);
struct dataStruct {
public DateTime timestamp { get; set; }
public decimal price { get; set; }
}
var dataStructCollection = new DataCollection<dataStruct>(100);
Data Collection allocates 40 bytes. Data that is stored in native memory that dynamically allocates. Calling Dispose frees memory immediately.
intCollection.Dispose();
dateTimeCollection.Dispose();
dataStructCollection.Dispose();
void Add(T element);
bool Remove(T element);
int IndexOf(T element);
bool Contains(T element);
int Count { get; }
T this[int index] { get; }
var string = JsonSerializer.Serialize(dataStructCollection);
[
{
"timestamp":"",
"price":1.04
},
{
"timestamp":"",
"price":1.04
}
]