Пример #1
0
 void Encode()
 {
     Assert.Equal("bcd", _coder.Encode("abc"));
     Assert.Equal("234", _coder.Encode("123"));
     Assert.Equal("yza", _coder.Encode("xyz"));
     Assert.Equal("анб", _coder.Encode("яма"));
 }
        public void Encode()
        {
            Dictionary <byte, int> symbolQuantityDic = createDictionary();
            var           builder      = new HuffmanCodecBuilder <byte>();
            var           tree         = builder.BuildTree(Comparer <byte> .Default, symbolQuantityDic);
            ICoder <byte> huffmanCoder = builder.GetCoder(tree);

            huffmanCoder.Encode(new StandardHuffmanCoderInput(inputReader), new HuffmanCoderOutput(coderOutputWriter));
            coderOutputWriter.CreateFileBytes(HuffmanEncodeModel.Standard, false, SymbolQuantityMapConverter.StandardIntToExtConvert(symbolQuantityDic, huffmanCoder.GetEncodingDictionary()));
        }
Пример #3
0
 public void Send(Protobuf protobuf)
 {
     if(socket == null || !socket.Connected)
     {
         UnityEngine.Debug.LogError("Socket was not established!");
         return;
     }
     beforeSendProto(protobuf);
     var data = coder.Encode(protobuf);
     socket.BeginSend(data, 0, data.Length, SocketFlags.None, beginSendCallback, socket);
 }
Пример #4
0
 private static string Encrypt(ICoder coder, string inputString)
 {
     return(coder.Encode(inputString));
 }
Пример #5
0
 void Encode()
 {
     Assert.Equal("zyx", _coder.Encode("abc"));
     Assert.Equal("cba", _coder.Encode("xyz"));
     Assert.Equal("яа", _coder.Encode("ая"));
 }
Пример #6
0
 private void encode(string source, ICoder coder)
 {
     _data = coder.Encode(source, out _length);
 }