本文整理汇总了C#中System.Collections.BitArray.Append方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.Append方法的具体用法?C# BitArray.Append怎么用?C# BitArray.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.BitArray
的用法示例。
在下文中一共展示了BitArray.Append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaveletTreeNodeBin
public WaveletTreeNodeBin(BitArray text, NodeList leaves)
{
List<bool> distinctChars = new List<bool>();
if (text.HasZeros())
distinctChars.Add(false);
if (text.HasOnes())
distinctChars.Add(true);
// Leaf Node
if (distinctChars.Count == 1) {
BitArray bitArray = new BitArray(text.Length);
bitString = new BitString(bitArray);
groupMembership = new Dictionary<bool, bool>();
groupMembership[text[0]] = false;
left = null;
right = null;
leaves.Add(text[0], this);
}
// Inner Node
else {
groupMembership = new Dictionary<bool, bool>(2);
groupMembership[false] = false;
groupMembership[true] = true;
BitArray group1 = new BitArray(0);
BitArray group2 = new BitArray(0);
BitArray bitArray = new BitArray(text.Length);
for (int i = 0; i < text.Length; i++) {
if (text[i] == false) {
group1 = group1.Append(false);
bitArray[i] = false;
}
else {
group2 = group2.Append(true);
bitArray[i] = true;
}
}
bitString = new BitString(bitArray);
left = new WaveletTreeNodeBin(group1, leaves);
right = new WaveletTreeNodeBin(group2, leaves);
left.parent = right.parent = this;
}
}
示例2: GenerateKeys
/// <summary>
/// 生成子密钥
/// </summary>
/// <param name="key">密钥</param>
/// <returns></returns>
private static BitArray[] GenerateKeys(BitArray key)
{
//置换选择1 64位->56位
key = SwapSelect1(key);
//Debug.WriteLine(key.PrintInBinary());
BitArray[] output = new BitArray[16];
BitArray c = new BitArray(28);
BitArray d = new BitArray(28);
c.SetRange(0, 28, key);
d.SetRange(0, 28, key, 28);
//Debug.WriteLine(c.PrintInBinary());
//Debug.WriteLine(d.PrintInBinary());
for (int i = 0; i < 16; i++)
{
//密钥产生
//循环左移
c = c.ROL(LeftShiftTime[i]);
d = d.ROL(LeftShiftTime[i]);
//Debug.WriteLine("i:{2} C:{0} D:{1}", c.PrintInBinary(), d.PrintInBinary(), i+1);
//置换选择2
output[i] = SwapSelect2(c.Append(d));
//Debug.WriteLine(output[i].PrintInBinary());
//Debug.WriteLine("C:{0} D:{1} out:{2}",c.PrintInHex(),d.PrintInHex(),output[i].PrintInHex());
}
return output;
}