Exemplo n.º 1
0
        // 向自己尾部添加一个 CirculeBuffer
        public void pushBackCB(CircularBuffer rhv)
        {
            if (m_dynBuffer.m_iCapacity - m_dynBuffer.m_size < rhv.size)
            {
                uint closeSize = DynBufResizePolicy.getCloseSize(rhv.size + m_dynBuffer.m_size, m_dynBuffer.m_iCapacity, m_dynBuffer.m_iMaxCapacity);
                setCapacity(closeSize);
            }
            //this.m_size += rhv.size;
            //this.m_last = this.m_size;

            //m_tmpBA.clear();
            rhv.frontBA(m_tmpBA, rhv.size);
            pushBackBA(m_tmpBA);

            //if (rhv.isLinearized()) // 如果是在一段内存空间
            //{
            //    Array.Copy(rhv.buff, rhv.first, m_buff, 0, rhv.size);
            //}
            //else    // 如果在两端内存空间
            //{
            //    Array.Copy(rhv.buff, rhv.first, m_buff, 0, rhv.capacity() - rhv.first);
            //    Array.Copy(m_buff, 0, m_buff, rhv.capacity() - rhv.first, rhv.last);
            //}
            //rhv.clear();
        }
Exemplo n.º 2
0
        /**
         *@brief 向存储空尾部添加一段内容
         */
        public void pushBackArr(byte[] items, uint start, uint len)
        {
            if (!canAddData(len)) // 存储空间必须要比实际数据至少多 1
            {
                uint closeSize = DynBufResizePolicy.getCloseSize(len + m_dynBuffer.m_size, m_dynBuffer.m_iCapacity, m_dynBuffer.m_iMaxCapacity);
                setCapacity(closeSize);
            }

            if (isLinearized())
            {
                if (len <= (m_dynBuffer.m_iCapacity - m_last))
                {
                    Array.Copy(items, start, m_dynBuffer.m_buff, m_last, len);
                }
                else
                {
                    Array.Copy(items, start, m_dynBuffer.m_buff, m_last, m_dynBuffer.m_iCapacity - m_last);
                    Array.Copy(items, m_dynBuffer.m_iCapacity - m_last, m_dynBuffer.m_buff, 0, len - (m_dynBuffer.m_iCapacity - m_last));
                }
            }
            else
            {
                Array.Copy(items, start, m_dynBuffer.m_buff, m_last, len);
            }

            m_last += len;
            m_last %= m_dynBuffer.m_iCapacity;

            m_dynBuffer.m_size += len;
        }
Exemplo n.º 3
0
        /**
         *@brief 向存储空头部添加一段内容
         */
        protected void pushFrontArr(byte[] items)
        {
            if (!canAddData((uint)items.Length)) // 存储空间必须要比实际数据至少多 1
            {
                uint closeSize = DynBufResizePolicy.getCloseSize((uint)items.Length + m_dynBuffer.m_size, m_dynBuffer.m_iCapacity, m_dynBuffer.m_iMaxCapacity);
                setCapacity(closeSize);
            }

            if (isLinearized())
            {
                if (items.Length <= m_first)
                {
                    Array.Copy(items, 0, m_dynBuffer.m_buff, m_first - items.Length, items.Length);
                }
                else
                {
                    Array.Copy(items, items.Length - m_first, m_dynBuffer.m_buff, 0, m_first);
                    Array.Copy(items, 0, m_dynBuffer.m_buff, m_dynBuffer.m_iCapacity - (items.Length - m_first), items.Length - m_first);
                }
            }
            else
            {
                Array.Copy(items, 0, m_dynBuffer.m_buff, m_first - items.Length, items.Length);
            }

            if (items.Length <= m_first)
            {
                m_first -= (uint)items.Length;
            }
            else
            {
                m_first = m_dynBuffer.m_iCapacity - ((uint)items.Length - m_first);
            }
            m_dynBuffer.m_size += (uint)items.Length;
        }
Exemplo n.º 4
0
 public void extendDeltaCapicity(uint delta)
 {
     capacity = DynBufResizePolicy.getCloseSize(size + delta, capacity, maxCapacity);
 }