コード例 #1
0
 public SveltoDictionaryKeyEnumerator
     (SveltoDictionary <TKey, TValue, TKeyStrategy, TValueStrategy, TBucketStrategy> dic) : this()
 {
     _dic   = dic;
     _index = -1;
     _count = (int)dic.count;
 }
コード例 #2
0
 public NativeEGIDMapper
     (ExclusiveGroupStruct groupStructId
     , SveltoDictionary <uint, T, NativeStrategy <FasterDictionaryNode <uint> >, NativeStrategy <T> > toNative) : this()
 {
     groupID = groupStructId;
     map     = toNative;
 }
コード例 #3
0
        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));
        }
コード例 #4
0
 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;
 }
コード例 #5
0
        public SveltoDictionaryKeyValueEnumerator
            (SveltoDictionary <TKey, TValue, TKeyStrategy, TValueStrategy, TBucketStrategy> dic) : this()
        {
            _dic   = dic;
            _index = -1;
#if DEBUG && !PROFILE_SVELTO
            _count = (int)dic.count;
#endif
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
 public TypeSafeDictionary(uint size, bool IsUnmanaged)
 {
     if (IsUnmanaged == false)
     {
         implementation = new SveltoDictionary <uint, TValue>(size, new ManagedStrategy <TValue>());
     }
     else
     {
         implementation = ConvertStructToUnmanaged <TValue> .create(size);
     }
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
        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
            }
        }
コード例 #11
0
        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;
        }
コード例 #12
0
        ///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));
        }
コード例 #13
0
 public ManagedTypeSafeDictionary(uint size)
 {
     implMgd =
         new SveltoDictionary <uint, TValue, ManagedStrategy <SveltoDictionaryNode <uint> >, ManagedStrategy <TValue>,
                               ManagedStrategy <int> >(size, Allocator.Managed);
 }
コード例 #14
0
        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();
        }
コード例 #15
0
 public ReadonlySveltoDictionaryNative(uint size, Allocator nativeAllocator)
 {
     _dictionary =
         new SveltoDictionary <TKey, TValue, NativeStrategy <SveltoDictionaryNode <TKey> >, NativeStrategy <TValue>,
                               NativeStrategy <int> >(size, nativeAllocator);
 }
コード例 #16
0
 public SveltoDictionaryKeyEnumerable(
     SveltoDictionary <TKey, TValue, TKeyStrategy, TValueStrategy, TBucketStrategy> dic)
 {
     _dic = dic;
 }
コード例 #17
0
 public FasterDictionaryKeyValueEnumerator(SveltoDictionary <TKey, TValue> dic) : this()
 {
     _dic   = dic;
     _index = -1;
     _count = (int)dic.count;
 }
コード例 #18
0
 internal ReadonlySveltoDictionaryNative
     (SveltoDictionary <TKey, TValue, NativeStrategy <SveltoDictionaryNode <TKey> >, NativeStrategy <TValue>,
                        NativeStrategy <int> > dic)
 {
     _dictionary = dic;
 }