https://github.com/simulation-tree/collections
Native C# library implementing collections
https://github.com/simulation-tree/collections
csharp dotnet nativeaot
Last synced: 5 months ago
JSON representation
Native C# library implementing collections
- Host: GitHub
- URL: https://github.com/simulation-tree/collections
- Owner: simulation-tree
- License: mit
- Created: 2024-10-30T20:49:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-24T03:03:20.000Z (9 months ago)
- Last Synced: 2025-09-24T05:18:27.758Z (9 months ago)
- Topics: csharp, dotnet, nativeaot
- Language: C#
- Homepage:
- Size: 256 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Collections
[](https://github.com/simulation-tree/collections/actions/workflows/test.yml)
Native C# library implementing collections.
### Installation
Install it by cloning it, or referencing through the NuGet package through GitHub's registry ([authentication info](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry#authenticating-to-github-packages)).
For installing as a Unity package, use these urls to add this repo and its dependency:
```
https://github.com/simulation-tree/collections.git?path=source#unity
https://github.com/simulation-tree/unmanaged.git?path=core#unity
```
### Arrays
```cs
using Array array = new(4);
array[0] = 1;
array[1] = 3;
array[2] = 3;
array[3] = 7;
foreach (int item in array)
{
Console.WriteLine(item);
}
```
### Lists
```cs
using List list = new();
list.Add(1);
list.Add(3);
list.Add(3);
list.Add(7);
foreach (int item in list)
{
Console.WriteLine(item);
}
```
### Dictionaries
```cs
using Dictionary dictionary = new();
dictionary.Add(1, 1337);
dictionary.Add(2, 8008135);
dictionary.Add(3, 42);
foreach ((byte key, int value) in dictionary)
{
Console.WriteLine($"{key} = {value}");
}
```
### Stacks
```cs
using Stack stack = new();
stack.Push(1);
stack.Push(3);
stack.Push(3);
stack.Push(7);
while (stack.TryPop(out int item))
{
Console.WriteLine(item);
}
```
### Queues
```cs
using Queue queue = new();
queue.Enqueue(1);
queue.Enqueue(3);
queue.Enqueue(3);
queue.Enqueue(7);
while (queue.TryDequeue(out int item))
{
Console.WriteLine(item);
}
```
### Hash sets
```cs
using HashSet hashSet = new();
hashSet.TryAdd(1);
hashSet.TryAdd(3);
hashSet.TryAdd(3);
hashSet.TryAdd(7);
foreach (int item in hashSet)
{
Console.WriteLine(item);
}
if (hashSet.TryGetValue(7, out int actualValue))
{
Console.WriteLine(actualValue);
}
```