Ejemplo n.º 1
0
 public BitsetDocSet(int nbits)
 {
     _bs = new BitSet(nbits);
 }
Ejemplo n.º 2
0
 public BitsDocIdSetIterator(BitSet bs)
 {
     _bs = bs;
     _current = -1;
 }
Ejemplo n.º 3
0
        // This is used by EnumSet for efficiency.
        public bool ContainsAll(BitSet other)
        {
            for (int i = other.bits.Length - 1; i >= 0; i--)
            {
                if ((bits[i] & other.bits[i]) != other.bits[i])
                    return false;
            }

            return true;
        }
Ejemplo n.º 4
0
 public BitsetDocSet()
 {
     _bs = new BitSet();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Performs the logical XOR operation on this bit set and the
 /// given <code>set</code>.  This means it builds the symmetric
 /// remainder of the two sets (the elements that are in one set,
 /// but not in the other).  The result is stored into this bit set,
 /// which grows as necessary.
 /// </summary>
 /// <param name="bs">the second bit set</param>
 public void XOr(BitSet bs)
 {
     Ensure(bs.bits.Length - 1);
     for (int i = bs.bits.Length - 1; i >= 0; i--)
         bits[i] ^= bs.bits[i];
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns true if the specified BitSet and this one share at least one
 /// common true bit.
 /// </summary>
 /// <param name="set">the set to check for intersection</param>
 /// <returns>true if the sets intersect</returns>
 public bool Intersects(BitSet set)
 {
     int i = Math.Min(bits.Length, set.bits.Length);
     while (--i >= 0)
     {
         if ((bits[i] & set.bits[i]) != 0)
             return true;
     }
     return false;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns a new <code>BitSet</code> composed of a range of bits from
        /// this one.
        /// </summary>
        /// <param name="from">the low index (inclusive)</param>
        /// <param name="to">the high index (exclusive)</param>
        /// <returns></returns>
        public BitSet Get(int from, int to)
        {
            if (from < 0 || from > to)
	            throw new ArgumentOutOfRangeException();
            BitSet bs = new BitSet(to - from);
            uint lo_offset = (uint)from >> 6;
            if (lo_offset >= bits.Length || to == from)
	            return bs;

            int lo_bit = from & LONG_MASK;
            uint hi_offset = (uint)to >> 6;
            if (lo_bit == 0)
            {
	            uint len = Math.Min(hi_offset - lo_offset + 1, (uint)bits.Length - lo_offset);
                Array.Copy(bits, lo_offset, bs.bits, 0, len);
	            if (hi_offset < bits.Length)
	            bs.bits[hi_offset - lo_offset] &= (1L << to) - 1;
	            return bs;
            }

            uint len2 = Math.Min(hi_offset, (uint)bits.Length - 1);
            int reverse = 64 - lo_bit;
            int i;
            for (i = 0; lo_offset < len2; lo_offset++, i++)
                bs.bits[i] = ((bits[lo_offset] >> lo_bit) | (bits[lo_offset + 1] << reverse));
            if ((to & LONG_MASK) > lo_bit)
	            bs.bits[i++] = bits[lo_offset] >> lo_bit;
            if (hi_offset < bits.Length)
	            bs.bits[i - 1] &= (1L << (to - from)) - 1;
            return bs;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Performs the logical AND operation on this bit set and the
 /// complement of the given <code>bs</code>.  This means it
 /// selects every element in the first set, that isn't in the
 /// second set.  The result is stored into this bit set and is
 /// effectively the set difference of the two.
 /// </summary>
 /// <param name="bs">the second bit set</param>
 public void AndNot(BitSet bs)
 {
     int i = Math.Min(bits.Length, bs.bits.Length);
     while (--i >= 0)
         bits[i] &= ~bs.bits[i];
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Performs the logical AND operation on this bit set and the
 /// given <code>set</code>.  This means it builds the intersection
 /// of the two sets.  The result is stored into this bit set.
 /// </summary>
 /// <param name="bs">the second bit set</param>
 public void And(BitSet bs)
 {
     int max = Math.Min(bits.Length, bs.bits.Length);
     int i;
     for (i = 0; i < max; ++i)
         bits[i] &= bs.bits[i];
     while (i < bits.Length)
         bits[i++] = 0;
 }