Lucene.Net.Util.OpenBitSet.Get C# (CSharp) Method

Get() public method

Returns true or false for the specified bit index.
public Get ( int index ) : bool
index int
return bool
		public virtual bool Get(int index)
		{
			int i = index >> 6; // div 64
			// signed shift will keep a negative index and force an
			// array-index-out-of-bounds-exception, removing the need for an explicit check.
			if (i >= internalbits.Length)
				return false;
			
			int bit = index & 0x3f; // mod 64
			long bitmask = 1L << bit;
			return (internalbits[i] & bitmask) != 0;
		}
		

Same methods

OpenBitSet::Get ( long index ) : bool

Usage Example

Example #1
0
        /// <summary>
        /// Asserts that the documents returned by <paramref name="q1"/>
        /// are a subset of those returned by <paramref name="q2"/>.
        /// <para/>
        /// Both queries will be filtered by <paramref name="filter"/>.
        /// </summary>
        protected virtual void AssertSubsetOf(Query q1, Query q2, Filter filter)
        {
            // TRUNK ONLY: test both filter code paths
            if (filter != null && Random.NextBoolean())
            {
                q1     = new FilteredQuery(q1, filter, TestUtil.RandomFilterStrategy(Random));
                q2     = new FilteredQuery(q2, filter, TestUtil.RandomFilterStrategy(Random));
                filter = null;
            }

            // not efficient, but simple!
            TopDocs td1 = m_s1.Search(q1, filter, m_reader.MaxDoc);
            TopDocs td2 = m_s2.Search(q2, filter, m_reader.MaxDoc);

            Assert.IsTrue(td1.TotalHits <= td2.TotalHits);

            // fill the superset into a bitset
            var bitset = new BitSet(td2.ScoreDocs.Length);

            for (int i = 0; i < td2.ScoreDocs.Length; i++)
            {
                bitset.Set(td2.ScoreDocs[i].Doc);
            }

            // check in the subset, that every bit was set by the super
            for (int i = 0; i < td1.ScoreDocs.Length; i++)
            {
                Assert.IsTrue(bitset.Get(td1.ScoreDocs[i].Doc));
            }
        }
All Usage Examples Of Lucene.Net.Util.OpenBitSet::Get