Example #1
0
        public void And(IntArrayFingerprint fingerprint)
        {
            List <int> tmp = new List <int>();
            int        i   = 0;
            int        j   = 0;

            while (i < trueBits.Length && j < fingerprint.trueBits.Length)
            {
                int local  = trueBits[i];
                int remote = fingerprint.trueBits[j];
                if (local == remote)
                {
                    tmp.Add(local);
                    i++;
                    j++;
                }
                else if (local < remote)
                {
                    i++;
                }
                else
                {
                    j++;
                }
            }
            trueBits = new int[tmp.Count];
            i        = 0;
            foreach (var t in tmp)
            {
                trueBits[i] = t;
            }
            Array.Sort(trueBits);
        }
Example #2
0
        public void Or(IntArrayFingerprint fingerprint)
        {
            var tmp = new HashSet <int>();

            {
                foreach (var trueBit in trueBits)
                {
                    tmp.Add(trueBit);
                }
            }
            {
                for (int i = 0; i < fingerprint.trueBits.Length; i++)
                {
                    tmp.Add(fingerprint.trueBits[i]);
                }
            }
            trueBits = new int[tmp.Count];
            {
                int i = 0;
                foreach (var t in tmp)
                {
                    trueBits[i++] = t;
                }
            }
            Array.Sort(trueBits);
        }
Example #3
0
        public void TestSetBit()
        {
            var fp = new IntArrayFingerprint();

            fp[1]   = true;
            fp[55]  = true;
            fp[219] = true;
            fp[3]   = true;
            fp[24]  = true;
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new int[] { 1, 3, 24, 55, 219 }, fp.GetSetBits()));
            fp[24] = false;
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new int[] { 1, 3, 55, 219 }, fp.GetSetBits()));
            fp[26] = false;
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new int[] { 1, 3, 26, 55, 219 }, fp.GetSetBits()));
        }
Example #4
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            IntArrayFingerprint other = (IntArrayFingerprint)obj;

            if (!Compares.AreEqual(trueBits, other.trueBits))
            {
                return(false);
            }
            return(true);
        }