コード例 #1
0
ファイル: PackedExponentTape.cs プロジェクト: nerai/Nibbler
 public bool Equals(
     PackedExponentTape t,
     ExponentComparison ec,
     bool ignoreTheirSuperfluousLeft,
     bool ignoreTheirSuperfluousRight)
 {
     if (t == null)
     {
         return(false);
     }
     return(true &&
            LeftSideEqualWith(t, ec, ignoreTheirSuperfluousLeft) &&
            RightSideEqualWith(t, ec, ignoreTheirSuperfluousRight));
 }
コード例 #2
0
ファイル: PackedExponentTape.cs プロジェクト: nerai/Nibbler
        public bool RightSideEqualWith(PackedExponentTape t, ExponentComparison ec, bool ignoreTheirSuperfluous)
        {
            if (t == null)
            {
                throw new ArgumentNullException();
            }

            if (_PositionInMacro != t._PositionInMacro)
            {
                return(false);
            }
            if (FacingRight != t.FacingRight)
            {
                return(false);
            }
            return(ContentEqualWith(ec, _R.First, t._R.First, ignoreTheirSuperfluous));
        }
コード例 #3
0
ファイル: PackedExponentTape.cs プロジェクト: nerai/Nibbler
        /// <summary>
        /// Compare cell contents.
        ///
        /// Begin is inclusive, end is exclusive (use null to compare to the end).
        /// </summary>
        private bool ContentEqualWith(
            ExponentComparison ec,
            Cell tape1,
            Cell tape2,
            bool ignoreSuperfluousTape2)
        {
            while (tape1 != null)
            {
                if (tape2 == null)
                {
                    return(false);
                }

                if (tape1.Data != tape2.Data)
                {
                    return(false);
                }
                if (ec == ExponentComparison.Ignore)
                {
                    // nothing
                }
                else if (ec == ExponentComparison.EqualityOfDirectComponent)
                {
                    if (tape1.Exponent != tape2.Exponent)
                    {
                        return(false);
                    }
                }
                else if (ec == ExponentComparison.TotalEquality)
                {
                    if (!tape1.Exponent.Equals(tape2.Exponent))
                    {
                        return(false);
                    }
                }

                tape1 = tape1.Next;
                tape2 = tape2.Next;
            }
            if (!ignoreSuperfluousTape2 && tape2 != null)
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
ファイル: PackedExponentTape.cs プロジェクト: nerai/nibbler
		/// <summary>
		/// Compare cell contents.
		///
		/// Begin is inclusive, end is exclusive (use null to compare to the end).
		/// </summary>
		private bool ContentEqualWith (
			ExponentComparison ec,
			Cell tape1,
			Cell tape2,
			bool ignoreSuperfluousTape2)
		{
			while (tape1 != null) {
				if (tape2 == null) {
					return false;
				}

				if (tape1.Data != tape2.Data) {
					return false;
				}
				if (ec == ExponentComparison.Ignore) {
					// nothing
				}
				else if (ec == ExponentComparison.EqualityOfDirectComponent) {
					if (tape1.Exponent != tape2.Exponent) {
						return false;
					}
				}
				else if (ec == ExponentComparison.TotalEquality) {
					if (!tape1.Exponent.Equals (tape2.Exponent)) {
						return false;
					}
				}

				tape1 = tape1.Next;
				tape2 = tape2.Next;
			}
			if (!ignoreSuperfluousTape2 && tape2 != null) {
				return false;
			}
			return true;
		}
コード例 #5
0
ファイル: PackedExponentTape.cs プロジェクト: nerai/nibbler
		public bool RightSideEqualWith (PackedExponentTape t, ExponentComparison ec, bool ignoreTheirSuperfluous)
		{
			if (t == null)
				throw new ArgumentNullException ();

			if (_PositionInMacro != t._PositionInMacro) {
				return false;
			}
			if (FacingRight != t.FacingRight) {
				return false;
			}
			return ContentEqualWith (ec, _R.First, t._R.First, ignoreTheirSuperfluous);
		}
コード例 #6
0
ファイル: PackedExponentTape.cs プロジェクト: nerai/nibbler
		public bool Equals (
			PackedExponentTape t,
			ExponentComparison ec,
			bool ignoreTheirSuperfluousLeft,
			bool ignoreTheirSuperfluousRight)
		{
			if (t == null) {
				return false;
			}
			return true
				&& LeftSideEqualWith (t, ec, ignoreTheirSuperfluousLeft)
				&& RightSideEqualWith (t, ec, ignoreTheirSuperfluousRight);
		}