bool ParseEqualityParameter(string p, out EqualityCheck value) { if (p.Equals("==")) { value = EqualityCheck.Equal; return(true); } if (p.Equals("!=")) { value = EqualityCheck.NotEqual; return(true); } if (p.Equals(">=")) { value = EqualityCheck.GtEqual; return(true); } if (p.Equals("<=")) { value = EqualityCheck.LtEqual; return(true); } value = EqualityCheck.Invalid; return(false); }
public ConditionalExpression(IMemoryReader memory, ushort lhs, EqualityCheck op, ushort rhs) { this.memory = memory; this.lhs = lhs; this.rhs = rhs; this.equalitycheck = op; }
public static void DetectDuplicates <T>(this IList <T> list, EqualityCheck <T> comparer, string warnMessage) { for (int i = 0; i < list.Count; ++i) { for (int j = i + 1; j < list.Count; ++j) { if (comparer(list[i], list[j])) { Debug.LogWarning(warnMessage); } } } }
/// <summary> /// Adds an <see cref="EqualityCheckerPipelineStage{TValue}"/> after this stage. /// </summary> /// <typeparam name="T">The type.</typeparam> /// <param name="stage">The stage to add equality checking for.</param> /// <param name="comparer">The compare function to use when comparing for equality.</param> /// <returns>The equality checking stage.</returns> public static IPipelineStage <T> WithEqualityCheck <T>(this IPipelineStage <T> stage, EqualityCheck <T> comparer) => new EqualityCheckerPipelineStage <T>(stage, comparer);
/// <summary> /// Creates a new <see cref="EqualityCheckerPipelineStage{TValue}"/> with the specified input and comparer. /// </summary> /// <param name="input">The input.</param> /// <param name="comparer">The comparer to use for equality.</param> /// <exception cref="ArgumentNullException">If <paramref name="input"/> or <paramref name="comparer"/> is null.</exception> public EqualityCheckerPipelineStage(IPipelineStage <TValue> input, EqualityCheck <TValue> comparer) { Input = input ?? throw new ArgumentNullException(nameof(input)); Comparer = comparer ?? throw new ArgumentNullException(nameof(comparer)); Name = "Equality check for: " + input.Name; LastValue = default !;
public EqualityOnlyComparer(EqualityCheck <T> equalityCheck) => EqualityCheck = equalityCheck ?? throw new ArgumentNullException(nameof(equalityCheck));
/// <summary> /// Creates an <see cref="IEqualityComparer{T}"/> from a function. /// Note that this comparer will retrieve hashcodes through the <c>GetHashCode()</c> method. /// </summary> /// <typeparam name="T">The type of object to check equality for.</typeparam> /// <param name="equalityCheck">The compare function to use.</param> /// <returns>An <see cref="IEqualityComparer{T}"/> created from the specified function. Hashcode is still retrieved through <code>x.GetHashCode()</code>.</returns> public static IEqualityComparer <T> Equality <T>(EqualityCheck <T> equalityCheck) => new EqualityOnlyComparer <T>(equalityCheck);