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


C# BitSet.Set方法代码示例

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


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

示例1: 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

示例2: 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:yao-yi,项目名称:BoboBrowse.Net,代码行数:58,代码来源:SparseFloatArray.cs

示例3: computeClasses

		private static void computeClasses(Spec spec)
		{
			SimplifyNfa.original_charset_size = spec.dtrans_ncols;
			SimplifyNfa.ccls = new char[SimplifyNfa.original_charset_size];
			char c = '\u0001';
			BitSet bitSet = new BitSet();
			BitSet bitSet2 = new BitSet();
			Dictionary<char, char> dictionary = new Dictionary<char, char>();
			Console.WriteLine("Working on character classes.");
			for (int i = 0; i < spec.nfa_states.Count; i++)
			{
				Nfa nfa = spec.nfa_states[i];
				if (nfa.Edge != '�' && nfa.Edge != '')
				{
					bitSet.ClearAll();
					bitSet2.ClearAll();
					for (int j = 0; j < SimplifyNfa.ccls.Length; j++)
					{
						if ((int)nfa.Edge == j || (nfa.Edge == '' && nfa.GetCharSet().contains(j)))
						{
							bitSet.Set((int)SimplifyNfa.ccls[j], true);
						}
						else
						{
							bitSet2.Set((int)SimplifyNfa.ccls[j], true);
						}
					}
					bitSet.And(bitSet2);
					if (bitSet.GetLength() != 0)
					{
						dictionary.Clear();
						for (int k = 0; k < SimplifyNfa.ccls.Length; k++)
						{
							if (bitSet.Get((int)SimplifyNfa.ccls[k]) && ((int)nfa.Edge == k || (nfa.Edge == '' && nfa.GetCharSet().contains(k))))
							{
								char c2 = SimplifyNfa.ccls[k];
								if (!dictionary.ContainsKey(c2))
								{
									Dictionary<char, char> arg_14F_0 = dictionary;
									char arg_14F_1 = c2;
									char expr_14A = c;
									c = (char)(expr_14A + '\u0001');
									arg_14F_0.Add(arg_14F_1, expr_14A);
								}
								SimplifyNfa.ccls[k] = dictionary[c2];
							}
						}
					}
				}
			}
			SimplifyNfa.mapped_charset_size = (int)c;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:52,代码来源:SimplifyNfa.cs

示例4: checkDuplicates

 public static void checkDuplicates(int[] array)
 {
     BitSet bs = new BitSet(32000);
     for (int i = 0; i < array.Length; i++)
     {
         int num = array[i];
         int num0 = num - 1; // bitset starts at 0, numbers start at 1
         if (bs.Get(num0))
         {
             Console.WriteLine(num);
         }
         else {
             bs.Set(num0);
         }
     }
 }
开发者ID:yusufbs,项目名称:CtCI-6th-Edition-CSharp,代码行数:16,代码来源:Q10_08_Find_Duplicates.cs

示例5: TestFilteredDocSetIterator

        public void TestFilteredDocSetIterator()
        {
            var set1 = new IntArrayDocIdSet();
            for (int i = 0; i < 100; i++)
            {
                set1.AddDoc(2 * i); // 100 even numbers
            }

            var filteredIter = new MyFilteredDocSetIterator(set1.Iterator());

            var bs = new BitSet(200);
            for (int i = 0; i < 100; ++i)
            {
                int n = 10 * i;
                if (n < 200)
                {
                    bs.Set(n);
                }
            }

            try
            {
                int doc;
                while ((doc = filteredIter.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (!bs.Get(doc))
                    {
                        Assert.Fail("failed: " + doc + " not in expected set");
                        return;
                    }
                    else
                    {
                        bs.Clear(doc);
                    }
                }
                if (bs.Cardinality() > 0)
                {
                    Assert.Fail("failed: leftover cardinality: " + bs.Cardinality());
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
开发者ID:modulexcite,项目名称:BoboBrowse.Net,代码行数:45,代码来源:FilterTest.cs

示例6: GetSwitchGroupAddress

		/// <summary>
		/// Convenience method for converting a string like "11011" to a
		/// <see cref="CyrusBuilt.MonoPi.BitSet"/>.
		/// </summary>
		/// <param name="address">
		/// The a string containing the address bits in sequence.
		/// </param>
		/// <returns>
		/// A bitset containing the address that can be used for swithing
		/// devices on or off.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="address"/> cannot be a null or empty string.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// <paramref name="address"/> must contain exactly 5 bits.
		/// </exception>
		public static BitSet GetSwitchGroupAddress(String address) {
			if (String.IsNullOrEmpty(address)) {
				throw new ArgumentNullException("address");
			}

			if (address.Length != 5) {
				throw new ArgumentException("address must consist of exactly 5 bits!");
			}

			BitSet bits = new BitSet(5);
			for (Int32 i = 0; i < 5; i++) {
				bits.Set(i, address[i] == '1');
			}
			return bits;
		}
开发者ID:cyrusbuilt,项目名称:MonoPi,代码行数:32,代码来源:RCSwitchDevice.cs

示例7: GetStates

		public BitSet GetStates()
		{
			BitSet bitSet = null;
			while (char.IsWhiteSpace(this.ibuf.line[this.ibuf.line_index]))
			{
				this.ibuf.line_index++;
				while (this.ibuf.line_index >= this.ibuf.line_read)
				{
					if (this.ibuf.GetLine())
					{
						return null;
					}
				}
			}
			if ('<' == this.ibuf.line[this.ibuf.line_index])
			{
				this.ibuf.line_index++;
				bitSet = new BitSet();
				while (true)
				{
					if (this.ibuf.line_index < this.ibuf.line_read)
					{
						while (true)
						{
							if (!char.IsWhiteSpace(this.ibuf.line[this.ibuf.line_index]))
							{
								if (',' != this.ibuf.line[this.ibuf.line_index])
								{
									break;
								}
								this.ibuf.line_index++;
							}
							else
							{
								this.ibuf.line_index++;
								while (this.ibuf.line_index >= this.ibuf.line_read)
								{
									if (this.ibuf.GetLine())
									{
										goto Block_6;
									}
								}
							}
						}
						if ('>' == this.ibuf.line[this.ibuf.line_index])
						{
							goto Block_9;
						}
						int line_index = this.ibuf.line_index;
						while (!char.IsWhiteSpace(this.ibuf.line[this.ibuf.line_index]) && this.ibuf.line[this.ibuf.line_index] != ',' && this.ibuf.line[this.ibuf.line_index] != '>')
						{
							this.ibuf.line_index++;
							if (this.ibuf.line_index >= this.ibuf.line_read)
							{
								break;
							}
						}
						int length = this.ibuf.line_index - line_index;
						string text = new string(this.ibuf.line, line_index, length);
						if (!this.spec.States.ContainsKey(text))
						{
							Console.WriteLine("Uninitialized State Name: [" + text + "]");
							Error.ParseError(Errors.STATE, this.inputFilePath, this.ibuf.line_number);
						}
						int bit = this.spec.States[text];
						bitSet.Set(bit, true);
					}
					else
					{
						if (this.ibuf.GetLine())
						{
							break;
						}
					}
				}
				Error.ParseError(Errors.EOF, this.inputFilePath, this.ibuf.line_number);
				return bitSet;
				Block_6:
				Error.ParseError(Errors.EOF, this.inputFilePath, this.ibuf.line_number);
				return bitSet;
				Block_9:
				this.ibuf.line_index++;
				if (this.ibuf.line_index < this.ibuf.line_read)
				{
					this.advance_stop = true;
				}
				return bitSet;
			}
			if (this.all_states == null)
			{
				this.all_states = new BitSet((bitSet != null) ? bitSet.Count : 0, true);
			}
			if (this.ibuf.line_index < this.ibuf.line_read)
			{
				this.advance_stop = true;
			}
			return this.all_states;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:98,代码来源:Gen.cs


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