public bool AddUniqueResult(Results2 res)
        {
            int rCount = res.Count;

            if (rCount <= 0)
            {
                return false;
            }
            int nRes = ResultSet.Count;
            for (int i = nRes - 1; i >= 0; --i)
            {
                int rsCount = ResultSet[i].Count;

                if (rsCount < rCount || res.Equals(ResultSet[i]))
                {
                    return false;
                }
                else if (rCount < rsCount)
                {
                    ResultSet.RemoveAt(i);
                }
            }

            if (rCount < BestSetSize)
            {
                BestSetSize = rCount;
            }

            ResultSet.Add(res);
            return true;
        }
Exemplo n.º 2
0
 public Results2 Clone()
 {
     Results2 ret = new Results2();
     int len = this.count;
     for (int i = 0; i < len; i++)
     {
         ret.lins[i] = this.lins[i];
     }
     ret.count = this.count;
     ret.values = this.values;
     return ret;
 }
Exemplo n.º 3
0
        public void TestResultSet()
        {
            List<MyPoint> set1 = new List<MyPoint>();
            set1.Add(new MyPoint(0, 0));
            set1.Add(new MyPoint(1, 1));
            set1.Add(new MyPoint(2, 2));
            set1.Add(new MyPoint(5, 0));
            set1.Add(new MyPoint(6, 1));
            set1.Add(new MyPoint(7, 2));

            ItemSet iSet1 = new ItemSet();
            ItemSet iSet2 = new ItemSet();

            iSet1.Add(0);
            iSet1.Add(2);
            iSet1.Add(4);

            iSet2.Add(1);
            iSet2.Add(3);
            iSet2.Add(5);

            Results2 r2 = new Results2();
            r2.AddResult(iSet1.GetIndices());

            Results2 r3 = r2.Clone();
            r3.AddResult(iSet2.GetIndices());

            Assert.AreEqual(2, r3.Count);
            Assert.AreEqual(1, r2.Count);

            ItemSet iSet3 = iSet1.Clone();
            iSet3.Add(1);
            iSet3.Add(3);
            iSet3.Add(5);

            Assert.AreEqual(3, iSet1.Count);
            Assert.AreEqual(6, iSet3.Count);
        }
Exemplo n.º 4
0
        public bool Equals(Results2 other)
        {
            //return this.count == other.count && this.values == other.values;
            int len = this.count;
            int oLen = other.count;
            if (len != oLen)
            {
                return false;
            }

            for (int i = 0; i < len; i++)
            {
                if (lins[i] != other.lins[i])
                {
                    return false;
                }
            }
            return true;
        }