コード例 #1
0
ファイル: QSU.cs プロジェクト: zekiguven/cdaapi_everest_CDA
        /// <summary>
        /// Determine equality between two QSS instances
        /// </summary>
        public bool Equals(QSU <T> other)
        {
            bool result = base.Equals(other);

            result &= this.Terms.Count == other.Terms.Count;
            for (int i = 0; i < other.Terms.Count && result; i++)
            {
                result &= this.Terms[i].Equals(other.Terms[i]);
            }
            return(result);
        }
コード例 #2
0
ファイル: SXPR.cs プロジェクト: zzllkk2003/everest
        /// <summary>
        /// Translate to a QSET data internally
        /// </summary>
        private QSET <T> TranslateToQSETInternal(SetOperator operation, List <SXCM <T> > collectedTerms, QSET <T> context)
        {
            // We need to construct the appropriate structure
            switch (operation)
            {
            case SetOperator.Exclusive:     // difference
            {
                // QSD must be broken into groups of two
                int     iofs    = 0;
                QSD <T> diffSet = null;
                if (context == null)         // Null, then the minuend is our first term
                {
                    diffSet = new QSD <T>(collectedTerms[0].TranslateToQSETComponent(), null);
                    iofs    = 1;
                }
                else         // Not, then the current QSET is the minuend
                {
                    diffSet = new QSD <T>(context, null);
                }
                for (int i = iofs; i < collectedTerms.Count; i++)
                {
                    diffSet.Subtrahend = collectedTerms[i].TranslateToQSETComponent();
                    if (i + 1 < collectedTerms.Count)         // We need to make a new QSD where this is the minuend
                    {
                        diffSet = new QSD <T>(diffSet, null);
                    }
                }
                context = diffSet;
                break;
            }

            case SetOperator.Inclusive:     // union is pretty easy
            {
                QSU <T> unionSet       = new QSU <T>();
                bool    isQssCandidate = true;
                if (context != null)
                {
                    isQssCandidate &= (context is QSS <T>) && (context as QSS <T>).Count() == 1;
                    unionSet.Add(context);
                }
                foreach (var itm in collectedTerms)
                {
                    var qsuItem = itm.TranslateToQSETComponent();
                    isQssCandidate &= (qsuItem is QSS <T>) && (qsuItem as QSS <T>).Count() == 1;
                    unionSet.Add(qsuItem);
                }

                // Is the union set composed entirely of QSS instances with one item?
                if (isQssCandidate)
                {
                    var qssSet = new QSS <T>();
                    foreach (var itm in unionSet)
                    {
                        qssSet.Add((itm as QSS <T>).First());
                    }
                    context = qssSet;
                }
                else
                {
                    context = unionSet;
                }
                break;
            }

            case SetOperator.Intersect:     // intersect, also pretty easy
            {
                QSI <T> intersectSet = new QSI <T>();
                if (context != null)
                {
                    intersectSet.Add(context);
                }
                foreach (var itm in collectedTerms)
                {
                    intersectSet.Add(itm.TranslateToQSETComponent());
                }
                context = intersectSet;
                break;
            }

            case SetOperator.PeriodicHull:     // periodic hull, same as difference
            {
                // QSP must be broken into groups of two
                int     iofs      = 0;
                QSP <T> periodSet = null;
                if (context == null)         // Null, then the minuend is our first term
                {
                    periodSet = new QSP <T>(collectedTerms[0].TranslateToQSETComponent(), null);
                    iofs      = 1;
                }
                else         // Not, then the current QSET is the minuend
                {
                    periodSet = new QSP <T>(context, null);
                }
                for (int i = iofs; i < collectedTerms.Count; i++)
                {
                    periodSet.High = collectedTerms[i].TranslateToQSETComponent();
                    if (i + 1 < collectedTerms.Count)         // We need to make a new QSD where this is the minuend
                    {
                        periodSet = new QSP <T>(periodSet, null);
                    }
                }
                context = periodSet;
                break;
            }

            case SetOperator.Hull:     // convex hull
            {
                throw new InvalidOperationException("Cannot represent a HULL value");
            }
            }

            return(context);
        }
コード例 #3
0
 /// <summary>
 /// Create a new instance of the GTS class with the specified <paramref name="hull"/>
 /// </summary>
 /// <param name="hull"></param>
 public GTS(QSU <TS> hull)
     : base()
 {
     this.Hull = hull;
 }