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


C# System.Collections.BitArray.Set方法代码示例

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


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

示例1: Bits

			public override System.Collections.BitArray Bits(IndexReader reader)
			{
				System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0?5 / 64:5 / 64 + 1) * 64);
				bitset.Set(1, true);
				bitset.Set(3, true);
				return bitset;
			}
开发者ID:runefs,项目名称:Marvin,代码行数:7,代码来源:TestFilteredQuery.cs

示例2: GetDocIdSet

			public override DocIdSet GetDocIdSet(IndexReader reader)
			{
				System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0?5 / 64:5 / 64 + 1) * 64);
				bitset.Set(1, true);
				bitset.Set(3, true);
				return new DocIdBitSet(bitset);
			}
开发者ID:Rationalle,项目名称:ravendb,代码行数:7,代码来源:TestFilteredQuery.cs

示例3: UriUtility

        static UriUtility()
        {
#if PORTABLE
            if (!Enum.TryParse("Compiled", out DefaultRegexOptions))
                DefaultRegexOptions = RegexOptions.None;
#else
            DefaultRegexOptions = RegexOptions.Compiled;
#endif

            _unreservedCharacters = new BitArray(256);
            for (char i = 'a'; i <= 'z'; i++)
                _unreservedCharacters.Set(i, true);
            for (char i = 'A'; i <= 'Z'; i++)
                _unreservedCharacters.Set(i, true);
            for (char i = '0'; i <= '9'; i++)
                _unreservedCharacters.Set(i, true);
            _unreservedCharacters.Set('-', true);
            _unreservedCharacters.Set('.', true);
            _unreservedCharacters.Set('_', true);
            _unreservedCharacters.Set('~', true);

            _generalDelimiters = new BitArray(256);
            _generalDelimiters.Set(':', true);
            _generalDelimiters.Set('/', true);
            _generalDelimiters.Set('?', true);
            _generalDelimiters.Set('#', true);
            _generalDelimiters.Set('[', true);
            _generalDelimiters.Set(']', true);
            _generalDelimiters.Set('@', true);

            _subDelimiters = new BitArray(256);
            _subDelimiters.Set('!', true);
            _subDelimiters.Set('$', true);
            _subDelimiters.Set('&', true);
            _subDelimiters.Set('(', true);
            _subDelimiters.Set(')', true);
            _subDelimiters.Set('*', true);
            _subDelimiters.Set('+', true);
            _subDelimiters.Set(',', true);
            _subDelimiters.Set(';', true);
            _subDelimiters.Set('=', true);
            _subDelimiters.Set('\'', true);

            _reservedCharacters = new BitArray(256).Or(_generalDelimiters).Or(_subDelimiters);

            _allowedHostCharacters = new BitArray(256).Or(_unreservedCharacters).Or(_subDelimiters);

            _allowedPathCharacters = new BitArray(256).Or(_unreservedCharacters).Or(_subDelimiters);
            _allowedPathCharacters.Set(':', true);
            _allowedPathCharacters.Set('@', true);

            _allowedQueryCharacters = new BitArray(256).Or(_allowedPathCharacters);
            _allowedQueryCharacters.Set('/', true);
            _allowedQueryCharacters.Set('?', true);

            _allowedFragmentCharacters = new BitArray(256).Or(_allowedPathCharacters);
            _allowedFragmentCharacters.Set('/', true);
            _allowedFragmentCharacters.Set('?', true);
        }
开发者ID:crowdy,项目名称:OpenStack-ConoHa,代码行数:59,代码来源:UriUtility.cs

示例4: UriUtility

        static UriUtility()
        {
            _unreservedCharacters = new BitArray(256);
            for (char i = 'a'; i <= 'z'; i++)
                _unreservedCharacters.Set(i, true);
            for (char i = 'A'; i <= 'Z'; i++)
                _unreservedCharacters.Set(i, true);
            for (char i = '0'; i <= '9'; i++)
                _unreservedCharacters.Set(i, true);
            _unreservedCharacters.Set('-', true);
            _unreservedCharacters.Set('.', true);
            _unreservedCharacters.Set('_', true);
            _unreservedCharacters.Set('~', true);

            _generalDelimiters = new BitArray(256);
            _generalDelimiters.Set(':', true);
            _generalDelimiters.Set('/', true);
            _generalDelimiters.Set('?', true);
            _generalDelimiters.Set('#', true);
            _generalDelimiters.Set('[', true);
            _generalDelimiters.Set(']', true);
            _generalDelimiters.Set('@', true);

            _subDelimiters = new BitArray(256);
            _subDelimiters.Set('!', true);
            _subDelimiters.Set('$', true);
            _subDelimiters.Set('&', true);
            _subDelimiters.Set('(', true);
            _subDelimiters.Set(')', true);
            _subDelimiters.Set('*', true);
            _subDelimiters.Set('+', true);
            _subDelimiters.Set(',', true);
            _subDelimiters.Set(';', true);
            _subDelimiters.Set('=', true);
            _subDelimiters.Set('\'', true);

            _reservedCharacters = new BitArray(256).Or(_generalDelimiters).Or(_subDelimiters);

            _allowedHostCharacters = new BitArray(256).Or(_unreservedCharacters).Or(_subDelimiters);

            _allowedPathCharacters = new BitArray(256).Or(_unreservedCharacters).Or(_subDelimiters);
            _allowedPathCharacters.Set(':', true);
            _allowedPathCharacters.Set('@', true);

            _allowedQueryCharacters = new BitArray(256).Or(_allowedPathCharacters);
            _allowedQueryCharacters.Set('/', true);
            _allowedQueryCharacters.Set('?', true);

            _allowedFragmentCharacters = new BitArray(256).Or(_allowedPathCharacters);
            _allowedFragmentCharacters.Set('/', true);
            _allowedFragmentCharacters.Set('?', true);
        }
开发者ID:charlyraffellini,项目名称:openstack.net,代码行数:52,代码来源:UriUtility.cs

示例5: BuildPatternBodyImpl

        protected override void BuildPatternBodyImpl(StringBuilder pattern, ICollection<string> requiredVariables, ICollection<string> arrayVariables, ICollection<string> mapVariables)
        {
            if (pattern == null)
                throw new ArgumentNullException("pattern");
            if (arrayVariables == null)
                throw new ArgumentNullException("arrayVariables");
            if (mapVariables == null)
                throw new ArgumentNullException("mapVariables");

            BitArray requiredPatterns = new BitArray(Variables.Count);
            List<string> variablePatterns = new List<string>();
            for (int i = 0; i < Variables.Count; i++)
            {
                VariableReference variable = Variables[i];
                if (requiredVariables.Contains(variable.Name))
                    requiredPatterns.Set(i, true);

                bool allowReservedSet = false;
                variablePatterns.Add(BuildVariablePattern(variable, allowReservedSet, null, requiredVariables, arrayVariables, mapVariables));
            }

            pattern.Append("(?:");
            AppendZeroOrMoreToEnd(pattern, requiredPatterns, variablePatterns, 0);
            pattern.Append(")");
        }
开发者ID:gitter-badger,项目名称:dotnet-uritemplate,代码行数:25,代码来源:UriTemplatePartLabelExpansion.cs

示例6: Bits

			public override System.Collections.BitArray Bits(IndexReader reader)
			{
				System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0 ? 5 / 64 : 5 / 64 + 1) * 64);
				for (int i = 0; i < 5; i++)
				{
					bitset.Set(i, true);
				} 
				return bitset;
			}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:9,代码来源:TestFilteredQuery.cs

示例7: Bits

		public override System.Collections.BitArray Bits(IndexReader reader)
		{
			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0 ? reader.MaxDoc() / 64 : reader.MaxDoc() / 64 + 1) * 64);

			for (int increment = 0; doc >= bits.Length; increment =+ 64)
			{
				bits.Length += increment;
			}
			bits.Set(doc, true);
			
			return bits;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:12,代码来源:SingleDocTestFilter.cs

示例8: TestRepeatedRollBacks

		public virtual void  TestRepeatedRollBacks()
		{
			
			int expectedLastRecordId = 100;
			while (expectedLastRecordId > 10)
			{
				expectedLastRecordId -= 10;
				RollBackLast(expectedLastRecordId);
				
				System.Collections.BitArray expecteds = new System.Collections.BitArray((100 % 64 == 0?100 / 64:100 / 64 + 1) * 64);
                for (int i = 1; i < (expectedLastRecordId + 1); i++) { expecteds.Set(i, true); }
				CheckExpecteds(expecteds);
			}
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:14,代码来源:TestTransactionRollback.cs

示例9: button_update_Click

        private void button_update_Click(object sender, EventArgs e)
        {
            System.Collections.BitArray bl, re, gr;
            bl = new System.Collections.BitArray(bitsfield.Count / 3);
            re = new System.Collections.BitArray(bitsfield.Count / 3);
            gr = new System.Collections.BitArray(bitsfield.Count / 3);
            Byte[] b = new Byte[resol * led_count / 8];
            Byte[] r = new Byte[resol * led_count / 8];
            Byte[] g = new Byte[resol * led_count / 8];
            for (int i = 0; i < bitsfield.Count; i += 24)
            {
                for (int j = 0; j < 8; j++)
                {
                    bl.Set(i / 3 + j, bitsfield.Get(i + (7 - j) * 3));
                    re.Set(i / 3 + j, bitsfield.Get(i + (7 - j) * 3 + 1));
                    gr.Set(i / 3 + j, bitsfield.Get(i + (7 - j) * 3 + 2));
                }
            }
            bl.CopyTo(b, 0);
            re.CopyTo(r, 0);
            gr.CopyTo(g, 0);
            String Bdata = "";
            String Rdata = "";
            String Gdata = "";

            for (int i = 0; i < (resol * led_count / 8); i++)
            {
                Bdata += BitConverter.ToString(b, i, 1);
                Rdata += BitConverter.ToString(r, i, 1);
                Gdata += BitConverter.ToString(g, i, 1);
            }
            String txt = "";
            for (int i = 0; i < (resol * led_count / 4); i += (led_count / 4))
            {
                txt += "0x";
                txt += Bdata.Substring(i, (led_count / 4));
                txt += ", 0x";
                txt += Rdata.Substring(i, (led_count / 4));
                txt += ", 0x";
                txt += Gdata.Substring(i, (led_count / 4));
                txt += ",\r\n";
            }
            this.textBox_data.Text = txt;
        }
开发者ID:bachdx60343,项目名称:pled,代码行数:44,代码来源:DataForm.cs

示例10: TstViaBitSet

		public virtual void  TstViaBitSet(int[] ints, int expectedByteSize)
		{
			int MAX_INT_FOR_BITSET = 1024 * 1024;
			//mgarski - BitArray cannot grow, so make as large as we would need it to be
			System.Collections.BitArray bs = new System.Collections.BitArray(MAX_INT_FOR_BITSET);
			for (int i = 0; i < ints.Length; i++)
			{
				if (ints[i] > MAX_INT_FOR_BITSET)
				{
					return ; // BitSet takes too much memory
				}
				if ((i > 0) && (ints[i - 1] == ints[i]))
				{
					return ; // BitSet cannot store duplicate.
				}
				bs.Set(ints[i], true);
			}
			SortedVIntList svil = new SortedVIntList(bs);
			TstVIntList(svil, ints, expectedByteSize);
			TstVIntList(new SortedVIntList(svil.Iterator()), ints, expectedByteSize);
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:21,代码来源:TestSortedVIntList.cs

示例11: BitSpans

		public override SpanFilterResult BitSpans(IndexReader reader)
		{
			
			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0 ? reader.MaxDoc() / 64 : reader.MaxDoc() / 64 + 1) * 64);
			Lucene.Net.Search.Spans.Spans spans = query.GetSpans(reader);
			System.Collections.IList tmp = new System.Collections.ArrayList(20);
			int currentDoc = - 1;
			SpanFilterResult.PositionInfo currentInfo = null;
			while (spans.Next())
			{
				int doc = spans.Doc();
				bits.Set(doc, true);
				if (currentDoc != doc)
				{
					currentInfo = new SpanFilterResult.PositionInfo(doc);
					tmp.Add(currentInfo);
					currentDoc = doc;
				}
				currentInfo.AddPosition(spans.Start(), spans.End());
			}
			return new SpanFilterResult(bits, tmp);
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:22,代码来源:SpanQueryFilter.cs

示例12: DoRandomSets

		internal virtual void  DoRandomSets(int maxSize, int iter, int mode)
		{
			System.Collections.BitArray a0 = null;
			OpenBitSet b0 = null;
			
			for (int i = 0; i < iter; i++)
			{
				int sz = rand.Next(maxSize);
				System.Collections.BitArray a = new System.Collections.BitArray(sz);
				OpenBitSet b = new OpenBitSet(sz);
				
				// test the various ways of setting bits
				if (sz > 0)
				{
					int nOper = rand.Next(sz);
					for (int j = 0; j < nOper; j++)
					{
						int idx;
						
						idx = rand.Next(sz);
						a.Set(idx, true);
						b.FastSet(idx);
						idx = rand.Next(sz);
						a.Set(idx, false);
						b.FastClear(idx);
						idx = rand.Next(sz);
						a.Set(idx, !a.Get(idx));
						b.FastFlip(idx);
						
						bool val = b.FlipAndGet(idx);
						bool val2 = b.FlipAndGet(idx);
						Assert.IsTrue(val != val2);
						
						val = b.GetAndSet(idx);
						Assert.IsTrue(val2 == val);
						Assert.IsTrue(b.Get(idx));
						
						if (!val)
							b.FastClear(idx);
						Assert.IsTrue(b.Get(idx) == val);
					}
				}
				
				// test that the various ways of accessing the bits are equivalent
				DoGet(a, b);
				
                // {{dougsale-2.4.0}}
                //
                // Java's java.util.BitSet automatically grows as needed - i.e., when a bit is referenced beyond
                // the size of the BitSet, an exception isn't thrown - rather, the set grows to the size of the 
                // referenced bit.
                //
                // System.Collections.BitArray does not have this feature, and thus I've faked it here by
                // "growing" the array explicitly when necessary (creating a new instance of the appropriate size
                // and setting the appropriate bits).
                //

                // test ranges, including possible extension
                int fromIndex, toIndex;
                fromIndex = rand.Next(sz + 80);
                toIndex = fromIndex + rand.Next((sz >> 1) + 1);

                // {{dougsale-2.4.0}}:
                // The following commented-out, compound statement's 'for loop' implicitly grows the Java BitSets 'a'
                // and 'aa' to the same cardinality as 'j+1' when 'a.Count < j+1' and 'fromIndex < toIndex':
                //BitArray aa = (BitArray)a.Clone(); for (int j = fromIndex; j < toIndex; j++) aa.Set(j, !a.Get(j));
                // So, if necessary, lets explicitly grow 'a' now; then 'a' and its clone, 'aa', will be of the required size.
                if (a.Count < toIndex && fromIndex < toIndex)
                {
                    System.Collections.BitArray tmp = new System.Collections.BitArray(toIndex, false);
                    for (int k = 0; k < a.Count; k++)
                        tmp.Set(k, a.Get(k));
                    a = tmp;
                }
                // {{dougsale-2.4.0}}: now we can invoke this statement without going 'out-of-bounds'
                System.Collections.BitArray aa = (System.Collections.BitArray)a.Clone(); for (int j = fromIndex; j < toIndex; j++) aa.Set(j, !a.Get(j));
                OpenBitSet bb = (OpenBitSet)b.Clone(); bb.Flip(fromIndex, toIndex);

                DoIterate(aa, bb, mode); // a problem here is from flip or doIterate

                fromIndex = rand.Next(sz + 80);
                toIndex = fromIndex + rand.Next((sz >> 1) + 1);
                // {{dougsale-2.4.0}}:
                // The following commented-out, compound statement's 'for loop' implicitly grows the Java BitSet 'aa'
                // when 'a.Count < j+1' and 'fromIndex < toIndex'
                //aa = (BitArray)a.Clone(); for (int j = fromIndex; j < toIndex; j++) aa.Set(j, false);
                // So, if necessary, lets explicitly grow 'aa' now
                if (a.Count < toIndex && fromIndex < toIndex)
                {
                    aa = new System.Collections.BitArray(toIndex);
                    for (int k = 0; k < a.Count; k++)
                        aa.Set(k, a.Get(k));
                }
                else
                {
                    aa = (System.Collections.BitArray)a.Clone();
                }
                for (int j = fromIndex; j < toIndex; j++) aa.Set(j, false);
                bb = (OpenBitSet)b.Clone(); bb.Clear(fromIndex, toIndex);

//.........这里部分代码省略.........
开发者ID:VirtueMe,项目名称:ravendb,代码行数:101,代码来源:TestOpenBitSet.cs

示例13: Bits

			public override System.Collections.BitArray Bits(IndexReader r)
			{
				System.Collections.BitArray b = new System.Collections.BitArray((r.MaxDoc() % 64 == 0?r.MaxDoc() / 64:r.MaxDoc() / 64 + 1) * 64);
				for (int i = 0; i < docs.Length; i++)
				{
					b.Set(docs[i], true);
				}
				return b;
			}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:9,代码来源:TestExplanations.cs

示例14: Bits

		/// <summary> Returns a BitSet with true for documents which should be
		/// permitted in search results, and false for those that should
		/// not.
		/// </summary>
		public override System.Collections.BitArray Bits(Monodoc.Lucene.Net.Index.IndexReader reader)
		{
			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
			TermEnum enumerator = reader.Terms(new Term(field, start));
			TermDocs termDocs = reader.TermDocs();
			if (enumerator.Term() == null)
			{
				return bits;
			}
			
			try
			{
				Term stop = new Term(field, end);
				while (enumerator.Term().CompareTo(stop) <= 0)
				{
					termDocs.Seek(enumerator.Term());
					while (termDocs.Next())
					{
						bits.Set(termDocs.Doc(), true);
					}
					if (!enumerator.Next())
					{
						break;
					}
				}
			}
			finally
			{
				enumerator.Close();
				termDocs.Close();
			}
			return bits;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:37,代码来源:DateFilter.cs

示例15: RandBitSet

		public virtual System.Collections.BitArray RandBitSet(int sz, int numBitsToSet)
		{
			System.Collections.BitArray set_Renamed = new System.Collections.BitArray((sz % 64 == 0 ? sz / 64 : sz / 64 + 1) * 64);
			for (int i = 0; i < numBitsToSet; i++)
			{
				set_Renamed.Set(r.Next(sz), true);
			}
			return set_Renamed;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:9,代码来源:TestScorerPerf.cs


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