Search Unity

NativeHasMap.GetKeyArray in job [alternatives]?

Discussion in 'Entity Component System' started by Mr-Mechanical, Jan 20, 2019.

  1. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    NativeHasMap.GetKeyArray returns a NativeArray which later has to be disposed if used inside Execute within a job. Disposing of a container in a job is a feature coming up in 2019.1. Any suggestions/workarounds meanwhile for getting keys in a job for hashmap iteration without disposing a nativecontainer? Thank you.
     
  2. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    wait. maybe I should just try 2019.1 alpha : ) ?
     
    Abbrew likes this.
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I was about to remove this from my library as I thought it wasn't required anymore but maybe there is still a use for it.
    https://forum.unity.com/threads/iterating-nativemultihashmap.611293/#post-4110970
    Doesn't return keys but returns an iterator for all key/value pairs so you could just use the key part if that's all you care about. Does not create a native container or produce any allocations.
     
    Mr-Mechanical likes this.