示例#1
0
        public int Intersection(SparseBooleanVector other)
        {
            int agg = 0;
            int i   = 0;
            int j   = 0;

            while (i < Keys.Length && j < other.Keys.Length)
            {
                int k1 = Keys[i];
                int k2 = other.Keys[j];

                if (k1 == k2)
                {
                    agg++;
                    i++;
                    j++;
                }
                else if (k1 < k2)
                {
                    i++;
                }
                else
                {
                    j++;
                }
            }

            return(agg);
        }
示例#2
0
 public int Union(SparseBooleanVector other)
 {
     return(this.Size + other.Size - this.Intersection(other));
 }
示例#3
0
        public double Jaccard(SparseBooleanVector other)
        {
            int intersection = this.Intersection(other);

            return((double)intersection / (this.Size + other.Size - intersection));
        }