BplusDotNet.BplusTree.BytesToString C# (CSharp) 메소드

BytesToString() 공개 정적인 메소드

public static BytesToString ( byte bytes ) : string
bytes byte
리턴 string
        public static string BytesToString(byte[] bytes)
        {
            System.Text.Decoder decode = System.Text.Encoding.UTF8.GetDecoder();
            long length = decode.GetCharCount(bytes, 0, bytes.Length);
            char[] chars = new char[length];
            decode.GetChars(bytes, 0, bytes.Length, chars, 0);
            string result = new String(chars);
            return result;
        }

Usage Example

예제 #1
0
        public void Load(byte[] serialization)
        {
            int index     = 0;
            int byteCount = serialization.Length;

            if (this.values.Count != 0 || this.keys.Count != 0)
            {
                throw new BplusTreeException("load into nonempty xBucket not permitted");
            }
            while (index < byteCount)
            {
                // get key prefix and key
                int keylength = BufferFile.Retrieve(serialization, index);
                index += BufferFile.INTSTORAGE;
                byte[] keybytes = new byte[keylength];
                Array.Copy(serialization, index, keybytes, 0, keylength);
                string keystring = BplusTree.BytesToString(keybytes);
                index += keylength;
                // get value prefix and value
                int valuelength = BufferFile.Retrieve(serialization, index);
                index += BufferFile.INTSTORAGE;
                byte[] valuebytes = new byte[valuelength];
                Array.Copy(serialization, index, valuebytes, 0, valuelength);
                // record new key and value
                this.keys.Add(keystring);
                this.values.Add(valuebytes);
                index += valuelength;
            }
            if (index != byteCount)
            {
                throw new BplusTreeException("bad byte count in serialization " + byteCount);
            }
        }
All Usage Examples Of BplusDotNet.BplusTree::BytesToString