Unity’s Native Collections package, currently in Preview, provides a hash map but not a hash set. Today we’ll supplement NativeHashMap<TKey, TValue>
with our own NativeHashSet<T>
as part of the NativeCollections repo. Read on for performance results and to see how to use it!
Posts Tagged native collection
Native collections are funny things. On one hand they’re structs, which are supposed to be value types that get copied on assignment. On the other hand, they act like reference types because they contain a hidden pointer internally. This can make using and implementing them difficult to understand, especially in the context of a ParallelFor job. Today we’ll examine more closely how to properly support ParallelFor jobs, especially with ranged containers like NativeList<T>
.
Last week we looked at a new native collection type: NativeChunkedList<T>
. This type saved us a lot of memory and gave us a faster way to dynamically grow an array. Unfortunately, iterating over it was quite a lot slower. Today we’ll speed it up for both IJob
and IJobParallelFor
. In doing so, we’ll learn more about how to create custom Unity job types and about how IEnumerable
and IEnumerator
work.
Today’s article is about a new native collection type: NativeChunkedList<T>. This type is great when you need a dynamically-resizable array that’s fast to add to and doesn’t waste a lot of memory. Read on to see how it’s implemented, see the performance report, and get the source code.
Last week’s article introduced two new native collection types: NativeIntPtr
and NativeLongPtr
. These were useful for both IJob
and IJobParallelFor
jobs, but performance was degraded in IJobParallelFor
. Today we’ll remedy that, explore some more aspects of Unity’s native collection and job systems, and learn more about CPU caches along the way.
Today we’ll add two new types to the Native Collections suite: NativeIntPtr
and NativeLongPtr
. We’ll make them usable with both IJob
and IJobParallelFor
and explore some new features Unity’s native container system along the way.
Last time in the series we encountered and overcame a host of esoteric issues on our path to a better understanding of Unity’s native collection system. This week we’ll continue on that journey and grapple with even more challenges in this new, unexplored area of Unity.
Continuing from last time, today we’ll greatly expand on the fledgling NativeLinkedList<T>
that we started last time. By the end of the article, we’ll have a useful native collection available to us!
Unity 2018.1 shipped with just one true native container: NativeArray<T>
. Now Unity 2018.2 has been released and there is still just the one native container. We’ve seen how to implement more, but never wrote much more than a proof of concept. Today we’ll begin implementing NativeLinkedList<T>
as an example of a native container for a very well known, simple data type. The result is available on GitHub for any project to use.