Build Core Branch Coverage NuGet License API Discord
Specialized .NET collections for hot paths that need tighter control over storage, allocation, iteration, and spatial queries.
The BCL collections are excellent defaults. SwiftCollections is for the code where profiling says the default is no longer enough: simulation loops, games, spatial indexing, deterministic runtimes, and allocation-sensitive tooling.
- Low-allocation lists, queues, stacks, hash tables, buckets, packed sets, sparse sets, and sparse maps.
- Dense iteration and stable or generation-checked handles for entity-style workloads.
- BVH, spatial hash, and octree queries over
System.Numericsvolumes. - Fixed-point query companions powered by FixedMathSharp.
- Explicit state-backed serialization, with Standard and Lean package variants.
- Benchmarks and full reachable coverage enforced as part of the repository workflow.
Choose one package family:
| Need | Package |
|---|---|
| Core collections with MemoryPack | SwiftCollections |
| Core collections without the MemoryPack runtime | SwiftCollections.Lean |
| FixedMathSharp spatial queries with MemoryPack | SwiftCollections.FixedMathSharp |
| FixedMathSharp spatial queries without the MemoryPack runtime | SwiftCollections.FixedMathSharp.Lean |
dotnet add package SwiftCollections
Or install a companion package when you need fixed-point query volumes. NuGet brings in the matching SwiftCollections and FixedMathSharp packages:
dotnet add package SwiftCollections.FixedMathSharp
Use the matching .Lean packages as a pair. Lean keeps the collection APIs but
removes the MemoryPack runtime; it is useful when your application owns its
serialization stack or wants the smaller dependency surface.
SwiftGenerationalBucket<T> gives you dense storage with handles that stop
resolving after their slot is reused:
using System; using SwiftCollections; var actors = new SwiftGenerationalBucket<string>(); SwiftHandle player = actors.Add("player"); if (actors.TryGet(player, out string actor)) { Console.WriteLine(actor); } actors.Remove(player);
For externally owned compact integer IDs, start with SwiftSparseSet or
SwiftSparseMap<T>. For broad-phase queries, start with SwiftBVH<TKey>,
SwiftSpatialHash<TKey>, or SwiftOctree<TKey>.
- Library overview and container guide
- Core API reference
- Spatial query API
- Coverage report
- Contributing and local validation
Using Unity? The maintained
SwiftCollections-Unity packages
add Unity-serializable adapters, Bounds conversions, GameObject pooling, and
FixedMathSharp integration.
The libraries target netstandard2.1 and net8.0. CI validates Standard and
Lean builds on Windows and Linux.
Questions and discussion are welcome in the Discord community. SwiftCollections is available under the MIT License.