Exemplo n.º 1
0
        public void Dump()
        {
            var binaryOut = new BinaryOut(_bitsPerLine);

            binaryOut.ResetTotal();
            binaryOut.Write(_text);
            Console.WriteLine($"{binaryOut.TotalBits} bits");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads a sequence of 8-bit extended ASCII characters over the alphabet
        /// { A, C, T, G } from standard input; compresses them using two bits per
        /// character; and writes the results to standard output.
        /// </summary>
        /// <param name="genome"></param>
        public void Compress(string genome)
        {
            //var n = genome.Length;
            //_binaryOut.Write(n);
            // Write two-bit code for char.
            _length = genome.Length;
            var list = new List <byte>();

            _bytes = ToByteList(list, genome);
            _binaryOut.ResetTotal();
            _binaryOut.Write(_bytes.ToArray());
            Console.WriteLine();
            Console.WriteLine(_binaryOut.TotalBits);

            _binaryOut.ResetTotal();
            _binaryOut.Write(genome);
            Console.WriteLine(_binaryOut.TotalBits);
        }
Exemplo n.º 3
0
        public void Run()
        {
            //Console.WriteLine("Choose file:"); // Prompt
            //Console.WriteLine("1 - tinyT.txt"); // Prompt
            //Console.WriteLine("2 - tinyW.txt"); // Prompt
            //Console.WriteLine("3 - largeT.txt"); // Prompt
            //Console.WriteLine("4 - largeW.txt"); // Prompt
            //Console.WriteLine("or quit"); // Prompt

            //var fileNumber = Console.ReadLine();
            //var fieName = string.Empty;
            //switch (fileNumber)
            //{
            //    case "1":
            //        fieName = "tinyT.txt";
            //        break;
            //    case "2":
            //        fieName = "tinyW.txt";
            //        break;
            //    case "3":
            //        fieName = "largeT.txt";
            //        break;
            //    case "4":
            //        fieName = "largeW.txt";
            //        break;
            //    case "quit":
            //        return;
            //    default:
            //        return;
            //}


            var binaryOut = new BinaryOut(16);

            binaryOut.Write((byte)6);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();


            binaryOut.Write(true);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();


            binaryOut.Write(false);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();


            binaryOut.Write(short.MaxValue);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write((short)5);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write(int.MaxValue);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write((int)5);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write(long.MaxValue);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();

            binaryOut.Write((long)5);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write(float.MaxValue);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write((float)5.0);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();


            binaryOut.Write(double.MaxValue);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write((double)5.0);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write(decimal.MaxValue);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();



            binaryOut.Write((decimal)5.0);
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();

            binaryOut.Write('r');
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();

            binaryOut.Write("test");
            Console.WriteLine(binaryOut.TotalBits);
            binaryOut.ResetTotal();
            Console.WriteLine();

            Console.ReadLine();
        }