当前位置: 首页>>代码示例>>C#>>正文


C# BitArray.HasZeros方法代码示例

本文整理汇总了C#中System.Collections.BitArray.HasZeros方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.HasZeros方法的具体用法?C# BitArray.HasZeros怎么用?C# BitArray.HasZeros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.BitArray的用法示例。


在下文中一共展示了BitArray.HasZeros方法的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;
        }
开发者ID:parrottsquawk,项目名称:School,代码行数:60,代码来源:BurrowsWheelerTransformBin.cs

示例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;
              }
        }
开发者ID:parrottsquawk,项目名称:School,代码行数:45,代码来源:WaveletTreeNodeBin.cs


注:本文中的System.Collections.BitArray.HasZeros方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。