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


C# BitSet类代码示例

本文整理汇总了C#中BitSet的典型用法代码示例。如果您正苦于以下问题:C# BitSet类的具体用法?C# BitSet怎么用?C# BitSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitSet类属于命名空间,在下文中一共展示了BitSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerfectDominatingSet

 public PerfectDominatingSet(int n)
     : base(n)
 {
     Sigma = new BitSet(0, MaxSize);
     Sigma = !Sigma;
     Rho = new BitSet(0, MaxSize, new int[] { 1 });
 }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:7,代码来源:PerfectDominatingSet.cs

示例2: Expand

        public static Tree Expand(Tree tree, BitSet parent, int node)
        {
            Tree newTree = new Tree();

            Queue<BitSet> queue = new Queue<BitSet>();
            queue.Enqueue(tree.Root);

            while (queue.Count > 0)
            {
                BitSet set = queue.Dequeue();
                BitSet child;
                if (tree.LeftChild.TryGetValue(set, out child))
                {
                    queue.Enqueue(child);
                }
                if (tree.RightChild.TryGetValue(set, out child))
                {
                    queue.Enqueue(child);
                }
                if (parent.IsSubsetOf(set))
                {
                    set += node;
                }

                newTree.Insert(set);
            }

            newTree.Insert(parent);
            newTree.Insert(newTree.Root * node);

            return newTree;
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:32,代码来源:ReductionRuleHelper.cs

示例3: IndependentSet

 public IndependentSet(int n)
     : base(n)
 {
     Sigma = new BitSet(0, MaxSize, new int[] { 0 });
     Rho = new BitSet(0, MaxSize);
     Rho = !Rho;
 }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:7,代码来源:IndependentSet.cs

示例4: InducedMatching

 public InducedMatching(int n)
     : base(n)
 {
     Sigma = new BitSet(0, MaxSize, new int[] { 1 });
     Rho = new BitSet(0, MaxSize);
     Rho = !Rho;
 }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:7,代码来源:InducedMatching.cs

示例5: CharSet

		static CharSet()
		{
			CharSet.lowerLetters = new BitSet();
			CharSet.upperLetters = new BitSet();
			CharSet.letters = new BitSet();
			for (int i = 0; i <= 65535; i++)
			{
				switch (char.GetUnicodeCategory((char)i))
				{
				case UnicodeCategory.UppercaseLetter:
					CharSet.upperLetters.Set(i, true);
					CharSet.letters.Set(i, true);
					break;
				case UnicodeCategory.LowercaseLetter:
					CharSet.lowerLetters.Set(i, true);
					CharSet.letters.Set(i, true);
					break;
				case UnicodeCategory.TitlecaseLetter:
				case UnicodeCategory.ModifierLetter:
				case UnicodeCategory.OtherLetter:
					CharSet.letters.Set(i, true);
					break;
				}
			}
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:25,代码来源:CharSet.cs

示例6: Connected

        // Uses depth-first search to check if the graph induced by the subgraph given as a parameter is connected
        // In other words, we retreive all edges from the original graph and check the subgraph for connectedness
        public static bool Connected(Datastructures.Graph graph, BitSet subgraph)
        {
            // Vertices that are visited
            Set<int> visited = new Set<int>();

            // Stack of vertices yet to visit
            Stack<int> stack = new Stack<int>();

            // Initial vertex
            int s = subgraph.First();
            stack.Push(s);

            // Continue while there are vertices on the stack
            while (stack.Count > 0)
            {
                int v = stack.Pop();

                // If we have not encountered this vertex before, then we check for all neighbors if they are part of the subgraph
                // If a neighbor is part of the subgraph it means that we have to push it on the stack to explore it at a later stage
                if (!visited.Contains(v))
                {
                    visited.Add(v);

                    foreach (int w in graph.OpenNeighborhood(v))
                        if (subgraph.Contains(w))
                            stack.Push(w);
                }
            }

            // If we visited an equal number of vertices as there are vertices in the subgraph then the subgraph is connected
            return visited.Count == subgraph.Count;
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:34,代码来源:DepthFirstSearch.cs

示例7: ProcessStates

		private static void ProcessStates(BitSet bset, Nfa current)
		{
			foreach (int current2 in bset)
			{
				List<Nfa> list = MakeNfa.spec.state_rules[current2];
				list.Add(current);
			}
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:8,代码来源:MakeNfa.cs

示例8: DNeighborhood

        // Basic constructor for a dNeighborhood
        public DNeighborhood(BitSet vector)
        {
            _occurrences = new Dictionary<int, int>();
            Vector = vector;

            foreach (int v in Vector)
                _occurrences[v] = 0;
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:9,代码来源:dNeighborhood.cs

示例9: DominatingSet

 public DominatingSet(int n)
     : base(n)
 {
     Sigma = new BitSet(0, MaxSize);
     Sigma = !Sigma;
     Rho = new BitSet(0, MaxSize, new int[] { 0 });
     Rho = !Rho;
 }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:8,代码来源:DominatingSet.cs

示例10: GhostObject

 public GhostObject()
 {
     Guid = new TFID();
     WaitingForParent = true;
     UpdatePriorityScalar = 0.1f;
     NetFlags = new BitSet();
     NetFlags.Set((UInt32) NetFlag.Ghostable);
 }
开发者ID:4ptiv4,项目名称:GenesisSharp,代码行数:8,代码来源:GhostObject.cs

示例11: CreateBitSet

		public void CreateBitSet()
		{
			BitSet b = new BitSet(32);
			b[0] = true;
			b[1] = false;
			Assert.IsTrue(b[0]);
			Assert.IsTrue(!b[1]);
		}
开发者ID:killbug2004,项目名称:reko,代码行数:8,代码来源:BitSetTests.cs

示例12: Condense

 protected virtual void Condense(float[] floats)
 {
     if (floats.Length != _capacity)
     {
         throw new ArgumentException("bad input float array of length " + floats.Length + " for capacity: " + _capacity);
     }
     var bits = new BitSet(floats.Length);
     int on = 0;
     for (int i = 0; i < floats.Length; i++)
     {
         if (floats[i] != 0f)
         {
             bits.Set(i);
             on++;
         }
     }
     if (((float)on) / ((float)floats.Length) < ON_RATIO_CUTOFF)
     {
         // it's worth compressing
         if (0 == on)
         {
             // it's worth super-compressing
             _floats = null;
             _bits = null;
             _referencePoints = null;
             // capacity is good.
         }
         else
         {
             _bits = bits;
             _floats = new float[_bits.Cardinality()];
             _referencePoints = new int[floats.Length / REFERENCE_POINT_EVERY];
             int i = 0;
             int floatsIdx = 0;
             int refIdx = 0;
             while (i < floats.Length && (i = _bits.NextSetBit(i)) >= 0)
             {
                 _floats[floatsIdx] = floats[i];
                 while (refIdx < i / REFERENCE_POINT_EVERY)
                 {
                     _referencePoints[refIdx++] = floatsIdx;
                 }
                 floatsIdx++;
                 i++;
             }
             while (refIdx < _referencePoints.Length)
             {
                 _referencePoints[refIdx++] = floatsIdx;
             }
         }
     }
     else
     {
         // it's not worth compressing
         _floats = floats;
         _bits = null;
     }
 }
开发者ID:modulexcite,项目名称:BoboBrowse.Net,代码行数:58,代码来源:SparseFloatArray.cs

示例13: LoadNameIndex

    static Dictionary<string,int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) {
      Dictionary<string, int> result = new Dictionary<string, int>();
      int ver;
      int sig;
      bits.ReadInt32(out ver);    //  0..3  Version
      bits.ReadInt32(out sig);    //  4..7  Signature
      bits.ReadInt32(out age);    //  8..11 Age
      bits.ReadGuid(out guid);       // 12..27 GUID

      if (ver != 20000404) {
        throw new PdbDebugException("Unsupported PDB Stream version {0}", ver);
      }

      // Read string buffer.
      int buf;
      bits.ReadInt32(out buf);    // 28..31 Bytes of Strings

      int beg = bits.Position;
      int nxt = bits.Position + buf;

      bits.Position = nxt;

      // Read map index.
      int cnt;        // n+0..3 hash size.
      int max;        // n+4..7 maximum ni.

      bits.ReadInt32(out cnt);
      bits.ReadInt32(out max);

      BitSet present = new BitSet(bits);
      BitSet deleted = new BitSet(bits);
      if (!deleted.IsEmpty) {
        throw new PdbDebugException("Unsupported PDB deleted bitset is not empty.");
      }

      int j = 0;
      for (int i = 0; i < max; i++) {
        if (present.IsSet(i)) {
          int ns;
          int ni;
          bits.ReadInt32(out ns);
          bits.ReadInt32(out ni);

          string name;
          int saved = bits.Position;
          bits.Position = beg + ns;
          bits.ReadCString(out name);
          bits.Position = saved;

          result.Add(name, ni);
          j++;
        }
      }
      if (j != cnt) {
        throw new PdbDebugException("Count mismatch. ({0} != {1})", j, cnt);
      }
      return result;
    }
开发者ID:BGCX261,项目名称:zoom-decompiler-hg-to-git,代码行数:58,代码来源:PdbFile.cs

示例14: BinaryReal

        public BinaryReal(BitSet bits, int numberOfBits, double lowerBound, double upperBound)
            : base(numberOfBits)
        {
            Bits = bits.Clone() as BitSet;
            LowerBound = lowerBound;
            UpperBound = upperBound;

            Decode();
        }
开发者ID:CRIAAC,项目名称:CSharpMetal,代码行数:9,代码来源:BinaryReal.cs

示例15: ComputeSequence

        private static UNSequence ComputeSequence(Datastructures.Graph graph, BitSet connectedComponent, CandidateStrategy candidateStrategy, int init, ref int max)
        {
            int n = graph.Size;
            List<int> sequence = new List<int>() { init };
            BitSet left = new BitSet(0, n, new int[] { init });
            BitSet right = connectedComponent - init;

            // Initially we store the empty set and the set with init as the representative, ie N(init) * right
            Set<BitSet> unLeft = new Set<BitSet>() { new BitSet(0, n), graph.OpenNeighborhood(init) * right };
            int value = int.MinValue;
            while (!right.IsEmpty)
            {
                Set<BitSet> unChosen = new Set<BitSet>();
                int chosen = Heuristics.TrivialCases(graph, left, right);

                if (chosen != -1)
                {
                    unChosen = IncrementUn(graph, left, unLeft, chosen);
                }
                // If chosen has not been set it means that no trivial case was found
                // Depending on the criteria for the next vertex we call a different algorithm
                else
                {
                    BitSet candidates = Heuristics.Candidates(graph, left, right, candidateStrategy);

                    int min = int.MaxValue;

                    foreach (int v in candidates)
                    {
                        Set<BitSet> unV = IncrementUn(graph, left, unLeft, v);
                        if (unV.Count < min)
                        {
                            chosen = v;
                            unChosen = unV;
                            min = unV.Count;
                        }
                    }
                }

                // This should never happen
                if (chosen == -1)
                    throw new Exception("No vertex is chosen for next step in the heuristic");

                // Add/remove the next vertex in the appropiate sets
                sequence.Add(chosen);
                left += chosen;
                right -= chosen;
                unLeft = unChosen;
                value = Math.Max(unChosen.Count, value);
                if (value > max)
                {
                    return new UNSequence() { Sequence = null, Value = int.MaxValue };
                }
            }

            return new UNSequence() { Sequence = sequence, Value = value };
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:57,代码来源:IUNHeuristic.cs


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