Skip to content

Latest commit

 

History

History
80 lines (59 loc) · 1.81 KB

README.md

File metadata and controls

80 lines (59 loc) · 1.81 KB

BanishedDev.Libs.Data

License Build Status Version

A library for operations on value type data. The main task is to limit the allocation of data on Heap.

Azure DevOps coverage

NuGet Package

dotnet add package BanishedDev.Libs.Data --version 0.1.0-dev.22301201

DataCollection

DataCollection<T> where T: unmanaged

Usage

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

IDisposable

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();

Methods

void Add(T element);
bool Remove(T element);
int IndexOf(T element);
bool Contains(T element);

Properties

int Count { get; }
T this[int index] { get; }

JsonSerialization

var string = JsonSerializer.Serialize(dataStructCollection);
[
    {
        "timestamp":"",
        "price":1.04
    },
    {
        "timestamp":"",
        "price":1.04
    }
]