daily update on 20240419 by nitload youmu, SSD merged into main stream
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using StgSharp.Data;
|
||||
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace SSD_Test
|
||||
{
|
||||
[TestClass]
|
||||
public class UnitTest1
|
||||
{
|
||||
//[TestMethod]
|
||||
public void TestCodeSeparate()
|
||||
{
|
||||
byte[] array = CodeSeparator.SeparateCode<byte>(
|
||||
Encoding.UTF8.GetBytes(
|
||||
"aewgyfhvbjaegfvbzgfaehdfkkdgshfskfgdsbvekawhvfbskgfhvzsdhgfhvsbdfhvdszbkgvhsbzvhvfsdvsdgfvhbdhvjeagfvshvghsf"));
|
||||
List<(byte, ulong)> list = CodeSeparator.CountCodeFrequency(array);
|
||||
foreach (var i in list)
|
||||
{
|
||||
Console.WriteLine($"{i.Item1}\t{i.Item2}");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
|
||||
HuffmanTree<byte> tree = HuffmanTree<byte>.BuildHuffmanTree(list);
|
||||
foreach (var i in tree.LeafList)
|
||||
{
|
||||
Console.WriteLine($"{i.Value}\t{i.frequency}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestIDenum()
|
||||
{
|
||||
Dictionary<byte,BitArray> test = new Dictionary<byte,BitArray>();
|
||||
for (int i = 101; i < 111; i++)
|
||||
{
|
||||
byte[] barray = [(byte)i];
|
||||
test.Add((byte)i, new BitArray(barray));
|
||||
}
|
||||
Console.WriteLine("-------------------------------");
|
||||
byte[] newbytes = Serializer.Serialize(test);
|
||||
foreach (var item in newbytes)
|
||||
{
|
||||
Console.Write(item);
|
||||
Console.Write("\t");
|
||||
}
|
||||
Console.WriteLine("\n--------------------------------");
|
||||
Dictionary<byte, BitArray> testOut;
|
||||
Serializer.Deserialize(newbytes,out testOut);
|
||||
foreach (var item in testOut)
|
||||
{
|
||||
Console.Write($"{item.Key}\t");
|
||||
foreach (var b in item.Value)
|
||||
{
|
||||
Console.Write($"{(bool)b}\t");
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user