/// <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.internalbits, b.internalbits, 0, System.Math.Min(a.wlen, b.wlen))); }
/* * 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(internalbits, 0, wlen)); }