示例#1
0
        public void CopyTo(VectorSegment <byte> vs)
        {
            var bytes = this.GetBytes();

            for (var i = 0; i < vs.Length; i++)
            {
                vs[i] = bytes[i];
            }
        }
示例#2
0
        public static short ToInt16(this VectorSegment <byte> vs)
        {
            if (vs.Length != 2)
            {
                throw new InvalidOperationException("Vector segment length must be exactly 2");
            }

            short n = 0, i = 16;

            foreach (var b in vs)
            {
                n += (short)(b << (i -= 8));
            }

            return(n);
        }
示例#3
0
        public static int ToInt32(this VectorSegment <byte> vs)
        {
            if (vs.Length != 4)
            {
                throw new InvalidOperationException("Vector segment length must be exactly 4");
            }

            int n = 0, i = 32;

            foreach (var b in vs)
            {
                n += b << (i -= 8);
            }

            return(n);
        }
示例#4
0
 public static int Read(this VectorSegment <byte> vs, Stream s)
 {
     return(s.Read(vs));
 }
示例#5
0
 public static int Read(this Stream s, VectorSegment <byte> vs)
 {
     return(s.Read(vs.array, vs.offset, vs.length));
 }
示例#6
0
 public Enumerator(VectorSegment <T> vs)
 {
     this.vs      = vs;
     this.current = -1;
 }