public static void Free(UnsafeHashMap *set) { if (set->_collection.Entries.Dynamic == 1) { UnsafeHashCollection.Free(&set->_collection); } Native.Free(set); }
public static void Free(UnsafeHashMap *set) { if (set->_collection.Entries.Dynamic) { UnsafeHashCollection.Free(&set->_collection); } AllocHelper.Free(set); }
public static void *GetPtr <K>(UnsafeHashMap *map, K key) where K : unmanaged, IEquatable <K> { var entry = UnsafeHashCollection.Find(&map->_collection, key, key.GetHashCode()); if (entry == null) { throw new KeyNotFoundException(key.ToString()); } return(GetValue(map, entry)); }
public static void Set <K>(UnsafeHashMap *map, K key, void *value, int size) where K : unmanaged, IEquatable <K> { var hash = key.GetHashCode(); var entry = UnsafeHashCollection.Find(&map->_collection, key, hash); if (entry == null) // insert new entry for key { entry = UnsafeHashCollection.Insert(&map->_collection, key, hash); } // assign value to entry UnsafeUtility.MemCpy(GetValue(map, entry), value, size); }
public static bool TryGetValuePtr <K, V>(UnsafeHashMap *map, K key, out V *val) where K : unmanaged, IEquatable <K> where V : unmanaged { var entry = UnsafeHashCollection.Find <K>(&map->_collection, key, key.GetHashCode()); if (entry != null) { val = (V *)GetValue(map, entry); return(true); } val = null; return(false); }
public static void Set <K, V>(UnsafeHashMap *map, K key, V value) where K : unmanaged, IEquatable <K> where V : unmanaged { var hash = key.GetHashCode(); var entry = UnsafeHashCollection.Find(&map->_collection, key, hash); if (entry == null) // insert new entry for key { entry = UnsafeHashCollection.Insert(&map->_collection, key, hash); } // assign value to entry *(V *)GetValue(map, entry) = value; }
public static void Add <K, V>(UnsafeHashMap *map, K key, V value) where K : unmanaged, IEquatable <K> where V : unmanaged { var hash = key.GetHashCode(); var entry = UnsafeHashCollection.Find <K>(&map->_collection, key, hash); if (entry == null) { // insert new entry for key entry = UnsafeHashCollection.Insert <K>(&map->_collection, key, hash); // assign value to entry *(V *)GetValue(map, entry) = value; } else { throw new InvalidOperationException(); } }
public static int Count(UnsafeHashMap *map) { return(map->_collection.UsedCount - map->_collection.FreeCount); }
public static int Capacity(UnsafeHashMap *map) { return(map->_collection.Entries.Length); }
static void *GetValue(UnsafeHashMap *map, UnsafeHashCollection.Entry *entry) { return((byte *)entry + map->_valueOffset); }
public static bool Remove <K>(UnsafeHashMap *map, K key) where K : unmanaged, IEquatable <K> { return(UnsafeHashCollection.Remove <K>(&map->_collection, key, key.GetHashCode())); }
public static bool ContainsKey <K>(UnsafeHashMap *map, K key) where K : unmanaged, IEquatable <K> { return(UnsafeHashCollection.Find <K>(&map->_collection, key, key.GetHashCode()) != null); }
public static Iterator <K, V> GetIterator <K, V>(UnsafeHashMap *map) where K : unmanaged where V : unmanaged { return(new Iterator <K, V>(map)); }
public static void Free(UnsafeHashMap *map) { AllocHelper.Free(map->_collection.Buckets); AllocHelper.Free(map->_collection.FreeHead); UnsafeBuffer.Free(&map->_collection.Entries); }
public Iterator(UnsafeHashMap *map) { _valueOffset = map->_valueOffset; _keyOffset = map->_collection.KeyOffset; _iterator = new UnsafeHashCollection.Iterator(&map->_collection); }
public DefaultSnapshotSerializer() { SystemToChunks = UnsafeHashMap.Allocate(64, sizeof(uint), UnsafeUtility.SizeOf <SystemChunkData>()); SystemToGhostIds = UnsafeHashMap.Allocate(64, sizeof(uint), UnsafeUtility.SizeOf <SystemGhostData>()); }
public static void Clear(UnsafeHashMap *set) { UnsafeHashCollection.Clear(&set->_collection); }
public void Allocate() { SystemData = UnsafeHashMap.Allocate <uint, IntPtr>(256); }
public void Allocate() { SystemData = UnsafePtrList.Create(256, Allocator.Persistent, NativeArrayOptions.ClearMemory); }