예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueMap{TKey, TValue}" /> struct.
        /// </summary>
        /// <param name="initialBuffer">The initial buffer.</param>
        public ValueMap(Span <KeyValueEntry <TKey, TValue> > initialBuffer)
        {
            if (initialBuffer.IsEmpty)
            {
                throw new ArgumentException("Buffer cannot be empty", nameof(initialBuffer));
            }

            _entries       = initialBuffer;
            _arrayFromPool = null;
            _count         = 0;
            _freeCount     = 0;
            _freeList      = -1;

            Initializate();
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueMap{TKey, TValue}" /> struct.
        /// </summary>
        /// <param name="initialCapacity">The initial capacity.</param>
        public ValueMap(int initialCapacity)
        {
            if (initialCapacity <= 0)
            {
                throw new ArgumentException("Initial capacity should be greater than 0");
            }

            _arrayFromPool = ArrayPool <KeyValueEntry <TKey, TValue> > .Shared.Rent(initialCapacity);

            _entries   = _arrayFromPool;
            _count     = 0;
            _freeCount = 0;
            _freeList  = -1;

            Initializate();
        }