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

            for (var i = 0; i < vs.Length; i++)
            {
                vs[i] = bytes[i];
            }
        }
Example #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);
        }
Example #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);
        }
Example #4
0
 public static int Read(this VectorSegment <byte> vs, Stream s)
 {
     return(s.Read(vs));
 }
Example #5
0
 public static int Read(this Stream s, VectorSegment <byte> vs)
 {
     return(s.Read(vs.array, vs.offset, vs.length));
 }
Example #6
0
 public Enumerator(VectorSegment <T> vs)
 {
     this.vs      = vs;
     this.current = -1;
 }