Esempio n. 1
0
        // Compare strings in the ByteBuffer.
        public static int CompareStrings(int offset_1, int offset_2, ByteBuffer bb)
        {
            offset_1 += bb.GetInt(offset_1);
            offset_2 += bb.GetInt(offset_2);
            var len_1      = bb.GetInt(offset_1);
            var len_2      = bb.GetInt(offset_2);
            var startPos_1 = offset_1 + sizeof(int);
            var startPos_2 = offset_2 + sizeof(int);
            var span_1     = bb.ToSpan(startPos_1, len_1);
            var span_2     = bb.ToSpan(startPos_2, len_2);

            return(span_1.SequenceCompareTo(span_2));
        }
Esempio n. 2
0
        // Get the data of a vector whoses offset is stored at "offset" in this object as an
        // Spant<byte>. If the vector is not present in the ByteBuffer,
        // then an empty span will be returned.
        public Span <byte> __vector_as_span(int offset)
        {
            var o = this.__offset(offset);

            if (0 == o)
            {
                return(new Span <byte>());
            }

            var pos = this.__vector(o);
            var len = this.__vector_len(o);

            return(bb.ToSpan(pos, len));
        }