Example #1
0
        protected override void InternalPeek(TKey key, TValue value)
        {
            byte *stream = Pointer + m_nextOffset;
            bool  endOfStream;

            m_encoding.Decode(stream, m_prevKey, m_prevValue, key, value, out endOfStream);
        }
        protected override void Read(int index, TKey key, TValue value)
        {
            byte *ptr = GetReadPointerAfterHeader() + index * KeyValueSize;

            m_encoding.Decode(ptr, null, null, key, value, out _);
            //key.Read(ptr);
            //value.Read(ptr + KeySize);
        }
        /// <summary>
        /// Attempts to read the next point from the stream.
        /// </summary>
        /// <param name="stream">The stream to read from</param>
        /// <param name="key">the key to store the value to</param>
        /// <param name="value">the value to store to</param>
        /// <returns>True if successful. False if end of the stream has been reached.</returns>
        public override bool TryDecode(BinaryStreamBase stream, TKey key, TValue value)
        {
            if (!m_encoding.ContainsEndOfStreamSymbol)
            {
                if (stream.ReadUInt8() == 0)
                {
                    return(false);
                }
            }

            m_encoding.Decode(stream, m_prevKey, m_prevValue, key, value, out bool endOfStream);
            key.CopyTo(m_prevKey);
            value.CopyTo(m_prevValue);
            return(!endOfStream);
        }
 protected int DecodeRecord(byte *stream, TKey prevKey, TValue prevValue, TKey currentKey, TValue currentValue)
 {
     return(m_encoding.Decode(stream, prevKey, prevValue, currentKey, currentValue, out _));
 }