Search Unity

Collection without duplicates in Job

Discussion in 'Entity Component System' started by sollniss, Aug 10, 2019.

  1. sollniss

    sollniss

    Joined:
    Aug 23, 2017
    Posts:
    11
    So, since there is no NativeHashSet or sets in general, I wanted to ask what the most performant way is to keep a collection duplication free right now.

    I've tried using a NativeHashMap with only using the keys, but it was much slower than a NativeList and checking for .IndexOf() each time.

    Is IndexOf the fastest we can get right now? Or should I allow duplicates and then deduplicate when converting the NativeList back to managed C# code?

    What's even the best method for converting a NativeCollection back to a managed one? So far I've found iterating over the NativeList and adding each element saparately to a C# List seems to be the most efficient way, since NativeList.ToList() is not available yet. Is it not possible to just copy over the memory somehow?