Пример #1
0
            public int Compare(object x, object y)
            {
                PairwiseTuple a = x as PairwiseTuple;
                PairwiseTuple b = y as PairwiseTuple;

                return(Compare(a, b));
            }
Пример #2
0
            public int Compare(PairwiseTuple a, PairwiseTuple b)
            {
                if (a == null)
                {
                    return(-1);
                }

                if (b == null)
                {
                    return(1);
                }

                if (a.Length < b.Length)
                {
                    return(-1);
                }

                if (b.Length > a.Length)
                {
                    return(1);
                }

                for (int i = 0; i < a.Length; ++i)
                {
                    int c;

                    c = a.names[i].CompareTo(b.names[i]);
                    if (c != 0)
                    {
                        return(c);
                    }

                    IComparable m = a[i].Value as IComparable;
                    IComparable n = b[i].Value as IComparable;

                    if (m == null)
                    {
                        return(-1);
                    }

                    if (n == null)
                    {
                        return(1);
                    }

                    c = m.CompareTo(n);

                    if (c != 0)
                    {
                        return(c);
                    }
                }

                // all value comparisons went okay
                return(0);
            }
Пример #3
0
            public int GetHashCode(PairwiseTuple tuple)
            {
                if (tuple == null)
                {
                    return(1);
                }

                int hash = 1;

                for (int i = 0; i < tuple.Length; ++i)
                {
                    hash = hash ^ tuple.names[i].GetHashCode();
                    hash = hash ^ tuple.values[i].GetHashCode();
                }

                return(hash);
            }
Пример #4
0
        public PairwiseTuple[] Generate(out PictExecutionInformation executionInformation)
        {
            string[][] results;
            string     pictModel = (string)this.Visit(model);

            // PictConstants.Trace("Pict model: {0}", model.Comment);
            string fn = settings.CanCache ? PictConstants.CacheFileName : null;

            using (PictRunner exec = new PictRunner(fn))
            {
                results = exec.MaybeExecutePict(settings, pictModel);
                executionInformation = exec.LastExecutionInformation;
                if (settings.RandomizeGeneration)
                {
                    settings.RandomSeed = executionInformation.RandomSeed;
                    // NOTE: not setting settings.RandomSeedSpecified
                }
            }

            // PictConstants.Trace("Results of executing PICT: {0}", results.Substring(0, Math.Min(255, results.Length)));
            int tupleLen = results[0].Length;

            PairwiseTuple[] tuples = new PairwiseTuple[results.Length - 1]; // skip the header
            string[]        fields = results[0];

            for (int tupleNumber = 0; tupleNumber < tuples.Length; ++tupleNumber)
            {
                // the line we access is actually '1-indexed': the first row is the fields
                string[]      line = results[tupleNumber + 1];
                PairwiseTuple pt   = new PairwiseTuple(fields);

                for (int currentField = 0; currentField < tupleLen; ++currentField)
                {
                    PairwiseValue value = context.FindValue(currentField, line[currentField]);

                    pt.Add(model.Parameters[currentField].Name, value);
                }

                tuples[tupleNumber] = pt;
            }

            return(tuples);
        }