Esempio n. 1
0
        public SveltoDictionary(uint size, Allocator nativeAllocator) : this()
        {
            //AllocationStrategy must be passed external for TValue because SveltoDictionary doesn't have struct
            //constraint needed for the NativeVersion
            _valuesInfo = default;
            _valuesInfo.Alloc(size, nativeAllocator);

            _buckets = new NativeStrategy <int>((uint)HashHelpers.GetPrime((int)size), nativeAllocator);

            _values = default;
            _values.Alloc(size, nativeAllocator);
        }
        public SveltoDictionary(uint size, IBufferStrategy <TValue> allocationStrategy)
        {
            //AllocationStrategy must be passed external for TValue because SveltoDictionary doesn't have struct
            //constraint needed for the NativeVersion
            if (UnmanagedTypeExtensions.IsUnmanaged <TKey>() == false ||
                UnmanagedTypeExtensions.IsUnmanaged <TValue>() == false)
            {
                _valuesInfo = new ManagedStrategy <FasterDictionaryNode <TKey> >(size);
            }
            else
            {
                _valuesInfo = new NativeStrategy <FasterDictionaryNode <TKey> >(size);
            }

            _buckets = new int[HashHelpers.GetPrime((int)size)];
            _values  = allocationStrategy;
            _values.Alloc(size);
        }