本文整理汇总了C#中System.Collections.BitArray.HasOnes方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.HasOnes方法的具体用法?C# BitArray.HasOnes怎么用?C# BitArray.HasOnes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.BitArray
的用法示例。
在下文中一共展示了BitArray.HasOnes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BurrowsWheelerTransformBin
/// <summary>
/// This method performs the BurrowsWheelerTransform algorithm on the input SuffixArray.
/// </summary>
/// <returns></returns>
public BurrowsWheelerTransformBin(SuffixArrayBin suffixArray)
{
textLength = suffixArray.InputText.Length;
List<BitArray> bwtTemp =
(suffixArray.Suffixes.Select(
i => new { i, lenSuffix = i.Length }).Select(
@t => @t.i.Append(suffixArray.InputText.Substring(0, textLength - @t.lenSuffix))
)
).ToList();
bwtTemp.Sort(
(BitArray bA, BitArray bB) => {
int order = 0;
for (int i = 0; i < Math.Max(bA.Length, bB.Length); i++) {
if (i >= bA.Length) {
order = -1;
break;
}
if (i >= bB.Length) {
order = 1;
break;
}
if (!bA[i] && bB[i]) {
order = -1;
break;
}
if (bA[i] && !bB[i]) {
order = 1;
break;
}
}
return order;
}
);
BitArray F = new BitArray(bwtTemp.Count);
BitArray L = new BitArray(bwtTemp.Count);
for (int i = 0; i < bwtTemp.Count; i++) {
F[i] = bwtTemp[i][0];
L[i] = bwtTemp[i][bwtTemp[i].Length - 1];
}
waveletTree = new WaveletTreeBin(L);
WaveletTreeBin waveletTreeF = new WaveletTreeBin(F);
C = new Dictionary<bool, int>(2);
if (F.HasZeros())
C[false] = waveletTreeF.Select(false, 1);
else
C[false] = -1;
if (F.HasOnes())
C[true] = waveletTreeF.Select(true, 1);
else
C[true] = -1;
}
示例2: 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;
}
}