public SveltoDictionaryKeyEnumerator (SveltoDictionary <TKey, TValue, TKeyStrategy, TValueStrategy, TBucketStrategy> dic) : this() { _dic = dic; _index = -1; _count = (int)dic.count; }
public NativeEGIDMapper (ExclusiveGroupStruct groupStructId , SveltoDictionary <uint, T, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <T> > toNative) : this() { groupID = groupStructId; map = toNative; }
public static NativeEGIDMultiMapper <T> QueryNativeMappedEntities <T>(this EntitiesDB entitiesDb, LocalFasterReadOnlyList <ExclusiveGroupStruct> groups) where T : unmanaged, IEntityComponent { var dictionary = new SveltoDictionary <ExclusiveGroupStruct, SveltoDictionary <uint, T, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <T>, NativeStrategy <int> >, NativeStrategy <FasterDictionaryNode <ExclusiveGroupStruct> >, NativeStrategy <SveltoDictionary <uint, T, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <T>, NativeStrategy <int> > >, NativeStrategy <int> > ((uint)groups.count, Allocator.TempJob); foreach (var group in groups) { if (entitiesDb.SafeQueryEntityDictionary <T>(group, out var typeSafeDictionary) == true) { if (typeSafeDictionary.count > 0) { dictionary.Add(group, ((TypeSafeDictionary <T>)typeSafeDictionary).implUnmgd); } } } return(new NativeEGIDMultiMapper <T>(dictionary)); }
public NativeEGIDMultiMapper (SveltoDictionary <ExclusiveGroupStruct, SveltoDictionary <uint, T, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <T> >, NativeStrategy <FasterDictionaryNode <ExclusiveGroupStruct> >, NativeStrategy < SveltoDictionary <uint, T, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <T> > > > dictionary) { _dic = dictionary; }
public SveltoDictionaryKeyValueEnumerator (SveltoDictionary <TKey, TValue, TKeyStrategy, TValueStrategy, TBucketStrategy> dic) : this() { _dic = dic; _index = -1; #if DEBUG && !PROFILE_SVELTO _count = (int)dic.count; #endif }
public NativeEGIDMapper (ExclusiveGroupStruct groupStructId , SveltoDictionary <uint, T, NativeStrategy <SveltoDictionaryNode <uint> >, NativeStrategy <T>, NativeStrategy <int> > toNative) : this() { groupID = groupStructId; _map = new SveltoDictionaryNative <uint, T>(); _map.UnsafeCast(toNative); }
public TypeSafeDictionary(uint size) { if (_isUmanaged) { implUnmgd = new SveltoDictionary <uint, TValue, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <TValue> >(size); } else { implMgd = new SveltoDictionary <uint, TValue, NativeStrategy <FasterDictionaryNode <uint> >, ManagedStrategy <TValue> >(size); } }
public TypeSafeDictionary(uint size, bool IsUnmanaged) { if (IsUnmanaged == false) { implementation = new SveltoDictionary <uint, TValue>(size, new ManagedStrategy <TValue>()); } else { implementation = ConvertStructToUnmanaged <TValue> .create(size); } }
public TypeSafeDictionary(uint size) { if (isUnmanaged) { implUnmgd = new SveltoDictionary <uint, TValue, NativeStrategy <SveltoDictionaryNode <uint> >, NativeStrategy <TValue>, NativeStrategy <int> >(size, Allocator.Persistent); } else { implMgd = new SveltoDictionary <uint, TValue, ManagedStrategy <SveltoDictionaryNode <uint> >, ManagedStrategy <TValue>, ManagedStrategy <int> >(size, Allocator.Managed); } }
public TypeSafeDictionary(uint size, bool IsUnmanaged) { if (IsUnmanaged == false) { implementation = new SveltoDictionary <uint, TValue>(size, new ManagedStrategy <TValue>()); } else { implementation = new SveltoDictionary <uint, TValue>(size, new NativeStrategy <TValue>()); #if DEBUG && !PROFILE_SVELTO //CheckProperDisposing.ToDispose.Add(implementation); #endif } }
public SharedSveltoDictionaryNative(uint size, Allocator allocatorStrategy = Allocator.Persistent) { var dictionary = new SveltoDictionary <TKey, TValue, NativeStrategy <SveltoDictionaryNode <TKey> >, NativeStrategy <TValue>, NativeStrategy <int> >(size, allocatorStrategy); _sharedDictionary = MemoryUtilities .Alloc <SveltoDictionary <TKey, TValue, NativeStrategy <SveltoDictionaryNode <TKey> >, NativeStrategy <TValue>, NativeStrategy <int> > >(1, allocatorStrategy); _allocatorStrategy = allocatorStrategy; this.dictionary = dictionary; }
///Note: if I use a SharedNativeSveltoDictionary for implUnmg, I may be able to cache NativeEGIDMultiMapper /// and reuse it public static NativeEGIDMultiMapper <T> QueryNativeMappedEntities <T>(this EntitiesDB entitiesDb, LocalFasterReadOnlyList <ExclusiveGroupStruct> groups, Allocator allocator) where T : unmanaged, IEntityComponent { var dictionary = new SveltoDictionary < /*key */ ExclusiveGroupStruct, /*value*/ SharedNative <SveltoDictionary <uint, T, NativeStrategy <SveltoDictionaryNode <uint> >, NativeStrategy <T>, NativeStrategy <int> > >, /*strategy to store the key*/ NativeStrategy <SveltoDictionaryNode <ExclusiveGroupStruct> >, /*strategy to store the value*/ NativeStrategy < SharedNative <SveltoDictionary <uint, T, NativeStrategy <SveltoDictionaryNode <uint> >, NativeStrategy <T>, NativeStrategy <int> > > > , NativeStrategy <int> > ((uint)groups.count, allocator); foreach (var group in groups) { if (entitiesDb.SafeQueryEntityDictionary <T>(group, out var typeSafeDictionary) == true) { //if (typeSafeDictionary.count > 0) dictionary.Add(group, ((TypeSafeDictionary <T>)typeSafeDictionary).implUnmgd); } } return(new NativeEGIDMultiMapper <T>(dictionary)); }
public ManagedTypeSafeDictionary(uint size) { implMgd = new SveltoDictionary <uint, TValue, ManagedStrategy <SveltoDictionaryNode <uint> >, ManagedStrategy <TValue>, ManagedStrategy <int> >(size, Allocator.Managed); }
public void TestSveltoDictionary(int dictionarysize) { SveltoDictionary <int, Test, NativeStrategy <SveltoDictionaryNode <int> >, NativeStrategy <Test>, NativeStrategy <int> > test = new SveltoDictionary <int, Test, NativeStrategy <SveltoDictionaryNode <int> >, NativeStrategy <Test>, NativeStrategy <int> >(1, Allocator.Persistent); int[] numbers = new int[dictionarysize]; for (int i = 1; i < dictionarysize; i++) { numbers[i] = numbers[i - 1] + i * HashHelpers.Expand((int)dictionarysize); } for (int i = 0; i < dictionarysize; i++) { test[i] = new Test(numbers[i]); } for (int i = 0; i < dictionarysize; i++) { if (test[i].i != numbers[i]) { throw new Exception(); } } for (int i = 0; i < dictionarysize; i += 2) { if (test.Remove(i) == false) { throw new Exception(); } } test.Clear(); for (int i = 0; i < dictionarysize; i++) { test[i] = new Test(numbers[i]); } for (int i = 1; i < dictionarysize - 1; i += 2) { if (test[i].i != numbers[i]) { throw new Exception(); } } for (int i = 0; i < dictionarysize; i++) { if (test[i].i != numbers[i]) { throw new Exception(); } } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { if (test.Remove(i) == false) { throw new Exception(); } } test.Clear(); for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { test[i] = new Test(numbers[i]); } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { if (test[i].i != numbers[i]) { throw new Exception(); } } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { if (test.Remove(i) == false) { throw new Exception(); } } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { if (test.Remove(i) == true) { throw new Exception(); } } test.Clear(); for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { test[i] = new Test(numbers[i]); } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { if (test.Remove(i) == false) { throw new Exception(); } } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { test[i] = new Test(numbers[i]); } for (int i = (int)(dictionarysize - 1); i >= 0; i -= 3) { if (test[i].i != numbers[i]) { throw new Exception(); } } test.Clear(); for (int i = 0; i < dictionarysize; i++) { test[numbers[i]] = new Test(i); } for (int i = 0; i < dictionarysize; i++) { Test JapaneseCalendar = test[numbers[i]]; if (JapaneseCalendar.i != i) { throw new Exception("read back test failed"); } } test.Clear(); for (int i = 0; i < dictionarysize; i++) { test[numbers[i]] = new Test(i); } for (int i = 0; i < dictionarysize; i++) { Test JapaneseCalendar = test[numbers[i]]; if (JapaneseCalendar.i != i) { throw new Exception("read back test failed"); } } test.Dispose(); }
public ReadonlySveltoDictionaryNative(uint size, Allocator nativeAllocator) { _dictionary = new SveltoDictionary <TKey, TValue, NativeStrategy <SveltoDictionaryNode <TKey> >, NativeStrategy <TValue>, NativeStrategy <int> >(size, nativeAllocator); }
public SveltoDictionaryKeyEnumerable( SveltoDictionary <TKey, TValue, TKeyStrategy, TValueStrategy, TBucketStrategy> dic) { _dic = dic; }
public FasterDictionaryKeyValueEnumerator(SveltoDictionary <TKey, TValue> dic) : this() { _dic = dic; _index = -1; _count = (int)dic.count; }
internal ReadonlySveltoDictionaryNative (SveltoDictionary <TKey, TValue, NativeStrategy <SveltoDictionaryNode <TKey> >, NativeStrategy <TValue>, NativeStrategy <int> > dic) { _dictionary = dic; }