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


C# BitSet.Get方法代码示例

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


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

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

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

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

示例4: GetCodeWordA

		/// <summary>
		/// Returns a 13 character array, representing the code word to be sent.
		/// A code word consists of 9 address bits, 3 data bits, and on sync bit
		/// but in our case, only the first 8 address bits and the last 2 data
		/// bits are used. A code bit can have 4 different states: "F" (floating),
		/// "1" (high), "0" (low), and "S" (synchronous bit).<br/><br/>
		/// +-------------------------------+--------------------------------+-----------------------------------------+-----------------------------------------+----------------------+------------+
		/// | 4 bits address (switch group) | 4 bits address (switch number) | 1 bit address (not used, so never mind) | 1 bit address (not used, so never mind) | 2 data bits (on|off) | 1 sync bit |
		/// | 1=0FFF 2=F0FF 3=FF0F 4=FFF0   | 1=0FFF 2=F0FF 3=FF0F 4=FFF0    | F | F | on=FF off=F0 | S |
		/// +-------------------------------+--------------------------------+-----------------------------------------+-----------------------------------------+----------------------+------------+
		/// <br/>
		/// </summary>
		/// <param name="groupAddress">
		/// A bitset containing 5 bits that represent the switch group address.
		/// </param>
		/// <param name="chan">
		/// The channel (switch) to manipulate.
		/// </param>
		/// <param name="status">
		/// Whether to switch on (true) or off (false).
		/// </param>
		/// <returns>
		/// If successful, a 13 character array containing the code word; Otherwise,
		/// a single-character array containing only a null-character.
		/// </returns>
		private String GetCodeWordA(BitSet groupAddress, ChannelCode chan, Boolean status) {
			Int32 returnPos = 0;
			char[] word = new char[13];
			String[] code = new String[6] { "FFFFF", "0FFFF", "F0FFF", "FF0FF", "FFF0F", "FFFF0" };
			if (((Int32)chan < 1) || ((Int32)chan > 5)) {
				return new String(new char[1] { '\0' });
			}

			for (Int32 i = 0; i < 5; i++) {
				if (!groupAddress.Get(i)) {
					word[returnPos++] = 'F';
				}
				else {
					word[returnPos++] = '0';
				}
			}

			for (Int32 j = 0; j < 5; j++) {
				word[returnPos++] = code[(Int32)chan][j];
			}

			if (status) {
				word[returnPos++] = '0';
				word[returnPos++] = 'F';
			}
			else {
				word[returnPos++] = 'F';
				word[returnPos++] = '0';
			}

			word[returnPos] = '\0';
			return new String(word);
		}
开发者ID:cyrusbuilt,项目名称:MonoPi,代码行数:58,代码来源:RCSwitchDevice.cs


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