initialPrefabs logo
  • Home 
  • Blog 
  • Games 
  • Tools 
  • Tags 
  1. Home
  2. Tools
  3. No Alloc Collections Documentation

No Alloc Collections Documentation

No Alloc Collections is a library that provides stack only data structures in C#. This means that you cannot store these collections as member variables in structs or classes and can only live in the closure they are declared.

You can store them in ref struct as they are within the closure of the stack.

All data structures must be backed by your custom allocated memory. This can be done through the stackalloc keyword or aliased as a span from a managed Array.

Installation  

  • For use within Unity please use OpenUpm.
  • For use with regular dotnet projects
    • You can embed the source directly into your project
    • Grab it on nuget
dotnet add package NoAllocCollections

Table of Contents  

  • MathUtils
  • NoAllocBitArray
  • NoAllocBitArrayEnumerator
  • NoAllocBitArrayExtensions
  • NoAllocEnumerator
  • NoAllocHashMap
  • NoAllocHashSet
  • NoAllocList
  • NoAllocListExtensions
  • NoAllocPriorityQueue
  • NoAllocQueue
  • NoAllocQueueExtensions

1 min read • Tools

MathUtils

MathUtils namespace InitialPrefabs.Collections Summary Convenience class for MathUtilities. int CeilToIntDivision(int numerator, int denominator) Summary Divides two integers and rounds it up to the nearest integer. ...

1 min read • Tools

NoAllocBitArray

NoAllocBitArray namespace InitialPrefabs.Collections Summary A stack only bitarray treats each bit as a boolean per byte. This means that each byte can store 8 booleans. int CalculateSize(int totalBools) Summary Calculates the total number of bytes the NoAllocBitArray can store. For example if you want to store 8 booleans, we will only need 1 byte. ...

1 min read • Tools

NoAllocBitArrayEnumerator

NoAllocBitArrayEnumerator namespace InitialPrefabs.Collections Summary A stack only enumerator to iterate through the NoAllocBitArray. bool MoveNext() Summary Increments the iterator. ...

1 min read • Tools

NoAllocBitArrayExtensions

NoAllocBitArrayExtensions namespace InitialPrefabs.Collections ref byte ElementAt(this ref NoAllocBitArray array, int i) Summary Returns the byte associated with a specific index you want to access. ...

1 min read • Tools

NoAllocEnumerator

NoAllocEnumerator namespace InitialPrefabs.Collections Summary A generic stack only iterator to be used with any kind of collection. TypeParam bool MoveNext() Summary Increments the iterator until it reaches the end of the collection. ...

1 min read • Tools

NoAllocHashMap

NoAllocHashMap namespace InitialPrefabs.Collections Summary A stack only dictionary that stores a key value pair. TypeParam Any type implementing IEquatable{T} ...

1 min read • Tools

NoAllocHashSet

NoAllocHashSet namespace InitialPrefabs.Collections Summary A stack only hashset that uses a Span{T} as its internal data structure. TypeParam Any type implementing IEquatable{T} ...

1 min read • Tools

NoAllocList

NoAllocList namespace InitialPrefabs.Collections Summary A stack only list backed by a Span{T}. The capacity is fixed, however the total number of elements are tracked. NoAllocEnumerator GetEnumerator() Go back to API Home ...

2 min read • Tools

NoAllocListExtensions

NoAllocListExtensions namespace InitialPrefabs.Collections void Clear(this ref NoAllocList list) Summary Resets the counter internally to 0. Does not clear out the memory so the elements still persist. As far as the list is aware, there is nothing stored. ...

2 min read • Tools

NoAllocPriorityQueue

NoAllocPriorityQueue namespace InitialPrefabs.Collections Summary A stack only priority queue is a queue that allows each item stored an assigned priority. The priority determines the order of service when an element is dequed. They can serve the highest priority or lowest priority based on the implementation of TComparer. ...

  • 1
  • 2
Follow Us!

Contact us if you want to work with us for your games and art projects!

     
Copyright © 2016-2026 InitialPrefabs
initialPrefabs
Code copied to clipboard