SwiftCollections 2.0.0
dotnet add package SwiftCollections --version 2.0.0
NuGet\Install-Package SwiftCollections -Version 2.0.0
<PackageReference Include="SwiftCollections" Version="2.0.0" />
<PackageVersion Include="SwiftCollections" Version="2.0.0" />
<PackageReference Include="SwiftCollections" />
paket add SwiftCollections --version 2.0.0
#r "nuget: SwiftCollections, 2.0.0"
#:package SwiftCollections@2.0.0
#addin nuget:?package=SwiftCollections&version=2.0.0
#tool nuget:?package=SwiftCollections&version=2.0.0
SwiftCollections
==============
![]()
SwiftCollections is a high-performance collection library for performance-sensitive .NET workloads, including game systems, simulations, and spatial queries.
๐ ๏ธ Key Features
- Optimized for Performance: Designed for low time complexity and minimal memory allocations.
- Unity-Compatible: Fully functional within Unity's ecosystem.
- Fast core collections:
SwiftDictionary,SwiftHashSet,SwiftList,SwiftQueue,SwiftStack,SwiftSortedList - Specialized containers:
SwiftBucket,SwiftGenerationalBucket,SwiftPackedSet,SwiftSparseMap,SwiftBiDictionary - Flat 2D/3D storage:
SwiftArray2D,SwiftArray3D,SwiftBoolArray2D,SwiftShortArray2D - Pools:
SwiftObjectPool,SwiftArrayPool,SwiftCollectionPool, and typed pool helpers - Observable collections for change-tracking scenarios
- Spatial queries via
SwiftBVHwith bothSystem.NumericsandFixedMathSharpbounds
Installation
NuGet
dotnet add package SwiftCollections
Source
git clone https://github.com/mrdav30/SwiftCollections.git
Then reference src/SwiftCollections/SwiftCollections.csproj or build the package locally.
Unity
Unity support is maintained separately:
๐งฉ Dependencies
๐ฆ Library Overview
Core Data Structures
- SwiftDictionary: A high-performance dictionary optimized for O(1) operations and minimal memory usage.
- SwiftBiDictionary: A bidirectional dictionary for efficient forward and reverse lookups in O(1).
- SwiftHashSet: An optimized set for unique values with fast operations.
- SwiftBucket: High-performance collection for O(1) addition and removal with stable indexing.
- SwiftGenerationalBucket: A bucket variant that tracks generations to prevent stale references.
- SwiftPackedSet: A compact set implementation for dense integer keys.
- SwiftSparseMap: A memory-efficient map for sparse key distributions.
- SwiftQueue: Circular-buffer-based queue for ultra-low-latency operations.
- SwiftList: A dynamic list optimized for speed-critical applications.
- SwiftSortedList: Dynamically sorted collection with O(log n) operations.
- SwiftStack: Fast array-based stack with O(1) operations.
- SwiftArray2D / SwiftArray3D: Efficient, flat-mapped arrays for 2D and 3D data.
- SwiftBVH: A Bounding Volume Hierarchy optimized for spatial queries.
Pools
- SwiftObjectPool: Thread-safe generic object pooling for improved memory usage and performance.
- SwiftArrayPool: Array-specific pool for efficient reuse of arrays.
- SwiftCollectionPool: Pool for reusable collection instances (e.g., List, HashSet).
Spatial Data Structures
- SwiftBVH: Bounding Volume Hierarchy for efficient spatial queries.
Observable Collections
- SwiftObservableArray / SwiftObservableList / SwiftObservableDictionary: Reactive, observable collections with property and collection change notifications.
๐ Usage Examples
SwiftBVH for Spatial Queries
var bvh = new SwiftBVH<int>(100);
var volume = new BoundingVolume(new Vector3(0, 0, 0), new Vector3(1, 1, 1));
bvh.Insert(1, volume);
var results = new List<int>();
bvh.Query(new BoundingVolume(new Vector3(0, 0, 0), new Vector3(2, 2, 2)), results);
Console.WriteLine(results.Count); // Output: 1
SwiftArray2D
var array2D = new Array2D<int>(10, 10);
array2D[3, 4] = 42;
Console.WriteLine(array2D[3, 4]); // Output: 42
SwiftQueue
var queue = new SwiftQueue<int>(10);
queue.Enqueue(5);
Console.WriteLine(queue.Dequeue()); // Output: 5
Populating Arrays
var array = new int[10].Populate(() => new Random().Next(1, 100));
๐งช Development
Build the solution:
dotnet build SwiftCollections.sln -c Debug
Run the unit tests:
dotnet test tests/SwiftCollections.Tests/SwiftCollections.Tests.csproj -c Debug --no-build
Run benchmarks:
dotnet run --project tests/SwiftCollections.Benchmarks/SwiftCollections.Benchmarks.csproj -c Release -f net8
Useful benchmark runner commands:
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 -- hashset --filter "*Contains*"
dotnet run --project tests/SwiftCollections.Benchmarks/SwiftCollections.Benchmarks.csproj -c Release -f net8 -- all --list flat
With no extra arguments, BenchmarkDotNet's default switcher behavior is used. Leading non-option arguments are treated as benchmark selection aliases, and any remaining arguments are forwarded to BenchmarkDotNet.
Compatibility
netstandard2.1net8.0- Windows, Linux, and macOS
FixedMathSharp is used for the fixed-point BVH path.
License
MIT. See LICENSE.md.
๐ฅ Contributors
- mrdav30 - Lead Developer
- Contributions are welcome! Feel free to submit pull requests or report issues.
๐ฌ Community & Support
For questions, discussions, or general support, join the official Discord community:
For bug reports or feature requests, please open an issue in this repository.
We welcome feedback, contributors, and community discussion across all projects.
| 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
- MemoryPack (>= 1.21.4)
-
net8.0
- MemoryPack (>= 1.21.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SwiftCollections:
| Package | Downloads |
|---|---|
|
GridForge
A high-performance, deterministic voxel grid system for spatial partitioning, simulation, and game development. |
GitHub repositories
This package is not used by any popular GitHub repositories.