/// <summary> /// Checks the equality with other assigned value. /// </summary> /// <param name="other">Other assigned value.</param> /// <returns>True if the objects are equal, false otherwise.</returns> public bool Equals(IAssignment other) { if (other == this) { return(true); } return(Variable == other.GetVariable() && Value == other.GetValue()); }
/// <summary> /// Checks whether the specified variable is actually affected by the operator effects. If the check is positive, returns /// also the effect application value. /// </summary> /// <param name="variable">Variable to be checked.</param> /// <param name="value">Applied value.</param> /// <returns>True if the given variable is affected by the effects, false otherwise.</returns> public bool IsVariableAffected(int variable, out int value) { foreach (var effect in this) { IAssignment assignment = effect.GetAssignment(); if (assignment.GetVariable() == variable) { value = assignment.GetValue(); return(true); } } value = Assignment.InvalidValue; return(false); }
/// <summary> /// Checks whether the state has the specified assignment. /// </summary> /// <param name="assignment">Assignment ot be checked.</param> /// <returns>True if the state has the given assignment, false otherwise.</returns> public bool HasValue(IAssignment assignment) { return(HasValue(assignment.GetVariable(), assignment.GetValue())); }
/// <summary> /// Sets the specified assignment in the state. /// </summary> /// <param name="assignment">Assignment ot be checked.</param> public void SetValue(IAssignment assignment) { SetValue(assignment.GetVariable(), assignment.GetValue()); }