Ejemplo n.º 1
0
        //compress

        /// <summary>
        /// 压缩
        /// </summary>
        public void compress()
        {
            byte[] b = BytesUtils.compressByteArr(_buf, 0, _length);

            _buf      = b;
            _position = 0;
            _length   = b.Length;
        }
Ejemplo n.º 2
0
        //uncompress

        /// <summary>
        /// 解压缩(0->length)无视position
        /// </summary>
        public void unCompress()
        {
            byte[] b = BytesUtils.uncompressByteArr(_buf, _off, _length);

            _buf      = b;
            _off      = 0;
            _position = 0;
            _length   = b.Length;
        }
Ejemplo n.º 3
0
        /** 扩容 */
        private void grow(int len)
        {
            int cap = BytesUtils.getCapacitySize(len);

            if (cap > _buf.Length)
            {
                byte[] bs = new byte[cap];

                Buffer.BlockCopy(_buf, 0, bs, 0, _buf.Length);

                _buf = bs;
            }
        }
Ejemplo n.º 4
0
 public override string ToString()
 {
     return(BytesUtils.bytesToString(_buf, _off, _length));
 }
Ejemplo n.º 5
0
        //check

        /// <summary>
        /// 获取某一段的字节hash(short)
        /// </summary>
        public short getHashCheck(int pos, int length)
        {
            return(BytesUtils.getHashCheck(_buf, pos + _off, length));
        }