Exemplo n.º 1
0
        public bool SetEquals(ExprCollection <T> other)
        {
            //new HashSet<T>().Set;
            if (Count != other.Count)
            {
                return(false);
            }

            var pQuery1 = this.OrderBy(e => e);
            var pQuery2 = other.OrderBy(e => e);
            var pEqual  = pQuery1.SequenceEqual(pQuery2);

            return(pEqual);

            //var pQuery1 = this.OrderBy(e => e).GetEnumerator();
            //var pQuery2 = other.OrderBy(e => e).GetEnumerator();
            //var hasNext = pQuery1.MoveNext() && pQuery2.MoveNext();

            //while (pQuery1.MoveNext() && pQuery2.MoveNext())
            //{
            //    var pCmp = pQuery1.Current.CompareTo(pQuery2.Current);

            //    if (pCmp != 0)
            //        return false;
            //}

            //return true;
        }
Exemplo n.º 2
0
        public int SetCompareTo(ExprCollection <T> other)
        {
            var pQuery1  = this.OrderBy(e => e).GetEnumerator();
            var pQuery2  = other.OrderBy(e => e).GetEnumerator();
            var hasNext1 = pQuery1.MoveNext();
            var hasNext2 = pQuery2.MoveNext();

            while (hasNext1 && hasNext2)
            {
                var pCmp = pQuery1.Current.CompareTo(pQuery2.Current);

                if (pCmp == 0)
                {
                    hasNext1 = pQuery1.MoveNext();
                    hasNext2 = pQuery2.MoveNext();
                }
                else
                {
                    return(pCmp);
                }
            }

            return((!hasNext1 && !hasNext2) ? 0 : (!hasNext1) ? -1 : 1);
        }