https://github.com/2a5f/coplt.sparsecollection
Fast, cache friendly, continuous memory sparse collections with CRUD all O(1)
https://github.com/2a5f/coplt.sparsecollection
collection sparse-list sparse-set
Last synced: 3 months ago
JSON representation
Fast, cache friendly, continuous memory sparse collections with CRUD all O(1)
- Host: GitHub
- URL: https://github.com/2a5f/coplt.sparsecollection
- Owner: 2A5F
- License: mit
- Created: 2024-05-08T11:55:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-31T08:15:30.000Z (11 months ago)
- Last Synced: 2025-03-20T11:41:55.280Z (3 months ago)
- Topics: collection, sparse-list, sparse-set
- Language: C#
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Coplt.SparseCollection
[](https://github.com/2A5F/Coplt.SparseCollection/actions/workflows/dotnet.yml)
[](https://www.nuget.org/packages/Coplt.SparseCollection/)
Fast, cache friendly, continuous memory sparse collections with CRUD all O(1)
### Example
- `SparseList`
```csharp
var list = new SparseList();
var id = list.Add(123);
list.Add(456);
list.Add(789);
if (list.ContainsId(id)) { }
if (list.TryGetValue(id, out var v) { }
var index = list.IndexById(id);
list[index] = 111;
list.RemoveAt(1);
list.RemoveById(id);
Span span = list.Values;
```- `PagedSparseSet`
```csharp
var list = new SparseList();
var set = new PagedSparseSet();
for (int i = 0; i < 1000; i++)
{
var id = list.Add(i);
set.Add(id, $"{i}");
}
```