Esempio n. 1
0
        public uint Add(T value)
        {
            for (int i = 0; i < (int)this.fastSegment.Length; i++)
            {
                if (this.fastSegment[i] == null)
                {
                    this.fastSegment[i] = value;
                    return((uint)i);
                }
            }
            if (this.slowSegment == null)
            {
                this.slowSegment = new Dictionary <uint, T>();
            }
            uint length = (uint)this.fastSegment.Length;

            while (length < this.maxHandle && this.slowSegment.ContainsKey(length))
            {
                length++;
            }
            if (length == this.maxHandle)
            {
                throw new AmqpException(AmqpError.ResourceLimitExceeded, SRAmqp.AmqpHandleExceeded(this.maxHandle));
            }
            this.slowSegment.Add(length, value);
            return(length);
        }