SwiftCollections.FixedMathSharp
7.0.0
dotnet add package SwiftCollections.FixedMathSharp --version 7.0.0
NuGet\Install-Package SwiftCollections.FixedMathSharp -Version 7.0.0
<PackageReference Include="SwiftCollections.FixedMathSharp" Version="7.0.0" />
<PackageVersion Include="SwiftCollections.FixedMathSharp" Version="7.0.0" />
<PackageReference Include="SwiftCollections.FixedMathSharp" />
paket add SwiftCollections.FixedMathSharp --version 7.0.0
#r "nuget: SwiftCollections.FixedMathSharp, 7.0.0"
#:package SwiftCollections.FixedMathSharp@7.0.0
#addin nuget:?package=SwiftCollections.FixedMathSharp&version=7.0.0
#tool nuget:?package=SwiftCollections.FixedMathSharp&version=7.0.0
SwiftCollections
![]()
SwiftCollections is a performance-oriented collection library for .NET systems that care about hot-path cost: simulations, games, spatial queries, deterministic runtimes, and allocation-sensitive tooling.
The standard .NET collections are excellent general-purpose defaults.
SwiftCollections is for the places where you need more control over storage
layout, pooling, dense iteration, externally owned integer IDs, deterministic
string hashing, or broad-phase spatial query structures. It is not meant to
replace every List<T> or Dictionary<TKey, TValue> in an application. It is
meant to give performance-critical code a sharper set of tools.
Why Use It
- Low-allocation collection types for repeated simulation and gameplay loops.
- Hash tables, lists, queues, stacks, buckets, packed sets, sparse sets, and sparse maps with APIs designed for predictable hot-path behavior.
- Dense integer-ID membership and value lookup through
SwiftSparseSetandSwiftSparseMap<T>. - Stable-handle storage through
SwiftBucket<T>and generation-checked handles throughSwiftGenerationalBucket<T>. - Spatial query structures: BVH, spatial hash, and octree implementations over
System.Numericsvolumes, plus fixed-point companions throughSwiftCollections.FixedMathSharp. - Optional MemoryPack serialization in standard packages, with lean variants for projects that want the same core APIs without MemoryPack.
- Benchmarks and high coverage are part of the repo workflow, not an afterthought.
Packages
Choose the package that matches your runtime and serialization needs.
| Package | Use When |
|---|---|
SwiftCollections |
You want the core collections with MemoryPack support. |
SwiftCollections.Lean |
You want the core collections without the MemoryPack dependency. |
SwiftCollections.FixedMathSharp |
You need fixed-point BVH, octree, or spatial hash volume wrappers backed by FixedMathSharp. |
SwiftCollections.FixedMathSharp.Lean |
You need the fixed-point companion without MemoryPack. |
Install the standard core, optionally with its fixed-point companion:
dotnet add package SwiftCollections
dotnet add package SwiftCollections.FixedMathSharp # optional
Or install the matching lean variants:
dotnet add package SwiftCollections.Lean
dotnet add package SwiftCollections.FixedMathSharp.Lean # optional
The standard and lean variants expose the same core collection APIs. The difference is whether MemoryPack is included. If you are targeting Unity Burst AOT or already have a serializer pipeline, prefer the lean variants.
Unity package support lives in a separate repository: SwiftCollections-Unity.
Documentation
- Documentation site
- Core API reference
- Spatial query API, including FixedMathSharp integrations
- Library overview
- Coverage report
Picking A Container
| Use case | Better fit |
|---|---|
| General key/value lookup with arbitrary keys | SwiftDictionary<TKey, TValue> |
| General unique values | SwiftHashSet<T> |
| Fast list, queue, stack, or sorted-list operations | SwiftList<T>, SwiftQueue<T>, SwiftStack<T>, SwiftSortedList<T> |
| Store objects and receive stable integer slots | SwiftBucket<T> |
| Store objects and guard against stale handles | SwiftGenerationalBucket<T> |
| Track membership for compact externally owned integer IDs | SwiftSparseSet |
| Attach values to compact externally owned integer IDs | SwiftSparseMap<T> |
| Store densely iterated unique values with hash-backed membership checks | SwiftPackedSet<T> |
| Arbitrary, huge, or widely sparse integer IDs | SwiftHashSet<int> or SwiftDictionary<int, T> |
| Broad-phase spatial queries | SwiftBVH<TKey>, SwiftSpatialHash<TKey>, SwiftOctree<TKey> |
More detail is available in the library overview.
Quick Examples
Sparse Membership For External IDs
using SwiftCollections;
var activeBodies = new SwiftSparseSet();
activeBodies.Add(42);
activeBodies.Add(128);
if (activeBodies.Contains(42))
{
activeBodies.Remove(42);
}
foreach (int bodyId in activeBodies)
{
// Dense iteration over active IDs.
}
var sortedBodyIds = new SwiftList<int>(activeBodies.Count);
activeBodies.CopySortedKeysTo(sortedBodyIds);
Sparse Values For External IDs
using System.Numerics;
using SwiftCollections;
var positions = new SwiftSparseMap<Vector3>();
positions[128] = new Vector3(10, 0, 4);
if (positions.TryGetValue(128, out Vector3 position))
{
positions[128] = position + new Vector3(1, 0, 0);
}
var sortedPositionIds = new SwiftList<int>(positions.Count);
positions.CopySortedKeysTo(sortedPositionIds);
Scratch List Sorting
using SwiftCollections;
var keys = new SwiftList<int> { 12, 4, 8 };
keys.SortInPlace();
// keys: 4, 8, 12
Stable Handles
using System;
using SwiftCollections;
var bodies = new SwiftGenerationalBucket<string>();
SwiftHandle handle = bodies.Add("player");
if (bodies.TryGet(handle, out string body))
{
Console.WriteLine(body);
}
bodies.Remove(handle);
Spatial Queries
using System.Numerics;
using SwiftCollections;
using SwiftCollections.Query;
var bvh = new SwiftBVH<int>(capacity: 128);
bvh.Insert(
1,
new BoundVolume(
new Vector3(0, 0, 0),
new Vector3(1, 1, 1)));
var results = new SwiftList<int>();
bvh.Query(
new BoundVolume(
new Vector3(-1, -1, -1),
new Vector3(2, 2, 2)),
results);
Serialization And Diagnostics
Most core types expose state-backed serialization support. Standard packages include MemoryPack support; lean packages compile the same public collection surface without taking a MemoryPack dependency. State-backed System.Text.Json conversion is available across the supported target frameworks.
Diagnostics are opt-in through SwiftCollections.Diagnostics. Disabled
diagnostic writes are designed to avoid doing formatting work when the requested
level is below the channel minimum, and guard helpers use lazy exception-message
formatting for condition-gated throws.
Development
Build the solution:
dotnet build SwiftCollections.slnx -c Debug
Run the unit tests:
dotnet test tests/SwiftCollections.Tests/SwiftCollections.Tests.csproj -c Debug --no-build
Run coverage with the shared runsettings:
dotnet test tests/SwiftCollections.Tests/SwiftCollections.Tests.csproj -c Debug --no-build --collect:"XPlat Code Coverage" --settings tests/SwiftCollections.Tests/coverlet.runsettings
Run benchmarks:
dotnet run --project tests/SwiftCollections.Benchmarks/SwiftCollections.Benchmarks.csproj -c Release -f net8 -- list
dotnet run --project tests/SwiftCollections.Benchmarks/SwiftCollections.Benchmarks.csproj -c Release -f net8 -- dictionary
dotnet run --project tests/SwiftCollections.Benchmarks/SwiftCollections.Benchmarks.csproj -c Release -f net8 -- query --list flat
dotnet run --project tests/SwiftCollections.Benchmarks/SwiftCollections.Benchmarks.csproj -c Release -f net8 -- all --list flat
Compatibility
- Library targets:
netstandard2.1andnet8.0 - Test target:
net8.0 - Benchmark target:
net8 - CI covers
ReleaseandReleaseLeanon Windows and Linux
Community And License
Questions and discussion are welcome in the Discord community. Bug reports and feature requests should be opened as GitHub issues.
SwiftCollections is licensed under the MIT License. See LICENSE, NOTICE, and
COPYRIGHT for license, branding, and authorship details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- FixedMathSharp (>= 7.0.0)
- SwiftCollections (>= 7.0.0)
-
net8.0
- FixedMathSharp (>= 7.0.0)
- SwiftCollections (>= 7.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SwiftCollections.FixedMathSharp:
| Package | Downloads |
|---|---|
|
GridForge
A high-performance, deterministic rectangular and hex-prism voxel grid system for spatial partitioning, simulation, and game development. |
|
|
Gravitas
High-performance, engine-agnostic fixed-point physics for deterministic 2D, 3D, and mixed-dimension lockstep games and simulations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.0 | 123 | 8/5/2026 |
| 6.0.0 | 174 | 7/1/2026 |
| 5.1.1 | 159 | 6/24/2026 |
| 5.1.0 | 111 | 6/22/2026 |
| 5.0.2 | 201 | 6/20/2026 |
| 5.0.1 | 229 | 6/16/2026 |
| 5.0.0 | 116 | 6/10/2026 |
| 4.1.1 | 115 | 5/30/2026 |
| 4.1.0 | 113 | 5/26/2026 |
| 4.0.5 | 117 | 5/19/2026 |
| 4.0.4 | 114 | 5/10/2026 |
| 4.0.3 | 112 | 5/7/2026 |
| 4.0.2 | 113 | 5/3/2026 |
| 4.0.0 | 115 | 4/16/2026 |