コード例 #1
0
 /// <summary>Returns the popcount or cardinality of the intersection of the two sets.
 /// Neither set is modified.
 /// </summary>
 public static long IntersectionCount(OpenBitSet a, OpenBitSet b)
 {
     return(BitUtil.Pop_intersect(a.bits, b.bits, 0, System.Math.Min(a.wlen, b.wlen)));
 }
コード例 #2
0
 /// <param name="tableSize"> Size of the hash table, should be a power of two.
 /// </param>
 /// <param name="maxChainLength"> Maximum length of each bucket, after which the oldest item inserted is dropped.
 /// </param>
 public SimpleStringInterner(int tableSize, int maxChainLength)
 {
     cache = new Entry[System.Math.Max(1, BitUtil.NextHighestPowerOfTwo(tableSize))];
     this.maxChainLength = System.Math.Max(2, maxChainLength);
 }
コード例 #3
0
        /*
         * public static int pop(long v0, long v1, long v2, long v3) {
         * // derived from pop_array by setting last four elems to 0.
         * // exchanges one pop() call for 10 elementary operations
         * // saving about 7 instructions... is there a better way?
         * long twosA=v0 & v1;
         * long ones=v0^v1;
         *
         * long u2=ones^v2;
         * long twosB =(ones&v2)|(u2&v3);
         * ones=u2^v3;
         *
         * long fours=(twosA&twosB);
         * long twos=twosA^twosB;
         *
         * return (pop(fours)<<2)
         + (pop(twos)<<1)
         + pop(ones);
         +
         + }
         */


        /// <returns> the number of set bits
        /// </returns>
        public virtual long Cardinality()
        {
            return(BitUtil.Pop_array(bits, 0, wlen));
        }