예제 #1
0
        //compress

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

            _buf      = b;
            _position = 0;
            _length   = b.Length;
        }
예제 #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;
        }
예제 #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;
            }
        }
예제 #4
0
 public override string ToString()
 {
     return(BytesUtils.bytesToString(_buf, _off, _length));
 }
예제 #5
0
        //check

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