private static int Apply(BoolOperator op, int u1, int u2) { int u; long key = gKey(u1, u2); if (G.ContainsKey(key)) { return(G[key]); } if (IsTerminal(u1) && IsTerminal(u2)) { u = op(u1, u2); } else { switch (Var(u1).CompareTo(Var(u2))) { case 0: //equals u = Mk(Var(u1), Apply(op, Low(u1), Low(u2)), Apply(op, High(u1), High(u2))); break; case -1: //less than u = Mk(Var(u1), Apply(op, Low(u1), u2), Apply(op, High(u1), u2)); break; default: //greater than u = Mk(Var(u2), Apply(op, u1, Low(u2)), Apply(op, u1, High(u2))); break; } } G.Add(key, u); return(u); }
public PollQuery WithShowOnHomePage(bool?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, BoolOperator @operator = BoolOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case BoolOperator.Equal: Entities = Entities.Where(p => p.ShowOnHomePage == value); return(this); case BoolOperator.NotEqual: Entities = Entities.Where(p => p.ShowOnHomePage != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public ScheduleTaskQuery WithStopOnError(bool?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, BoolOperator @operator = BoolOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case BoolOperator.Equal: Entities = Entities.Where(st => st.StopOnError == value); return(this); case BoolOperator.NotEqual: Entities = Entities.Where(st => st.StopOnError != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public FriendRequestQuery WithBlockSubsequentRequests(bool?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, BoolOperator @operator = BoolOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case BoolOperator.Equal: Entities = Entities.Where(fr => fr.BlockSubsequentRequests == value); return(this); case BoolOperator.NotEqual: Entities = Entities.Where(fr => fr.BlockSubsequentRequests != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
private BoolExprTreeNode(string literal) { _op = BoolOperator.LEAF; _left = null; _right = null; _literal = literal; }
/// <summary> /// Deeply copies the subtree starting from the specified node. /// </summary> /// <param name="other"></param> public BoolExprTreeNode(BoolExprTreeNode other) { _op = other._op; _left = other._left == null ? null : new BoolExprTreeNode(other._left); _right = other._right == null ? null : new BoolExprTreeNode(other._right); _literal = new StringBuilder(other._literal).ToString(); }
public void Dispose() { _op = BoolOperator.LEAF; _left = null; _right = null; _literal = null; }
// // Private constructors // private BoolExprTreeNode(BoolOperator op, BoolExprTreeNode left, BoolExprTreeNode right) { _op = op; _left = left; _right = right; _literal = null; }
public EmailAccountQuery WithUseDefaultCredentials(bool?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, BoolOperator @operator = BoolOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case BoolOperator.Equal: Entities = Entities.Where(ea => ea.UseDefaultCredentials == value); return(this); case BoolOperator.NotEqual: Entities = Entities.Where(ea => ea.UseDefaultCredentials != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public OrderNoteQuery WithIsPublic(bool?value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, BoolOperator @operator = BoolOperator.Equal) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case BoolOperator.Equal: Entities = Entities.Where(on => on.IsPublic == value); return(this); case BoolOperator.NotEqual: Entities = Entities.Where(on => on.IsPublic != value); return(this); default: throw new NotSupportedEnumException(@operator); } }
public BoolOperatorInstruction(BoolOperator oper, string variable1, bool a2, string variable) { this.oper = oper; this.variable1 = variable1; this.a2 = (object)(bool)(a2); this.variable = variable; this.ifvariable1 = true; this.ifvariable2 = false; }
public BoolOperatorInstruction(BoolOperator oper, object a1, object a2, string variable) { this.oper = oper; this.a1 = a1; this.a2 = a2; this.variable = variable; this.ifvariable1 = false; this.ifvariable2 = false; }
public BoolExpression(BoolOperator op, ArithExpression arith1, ArithExpression arith2) { //Postcondition: Creates a new BoolExpression using op, arith1, and arith2 if (arith1 == null || arith2 == null) { throw new Exception("Null ArithExpression inputted into new BoolExpression"); } this.arith1 = arith1; this.arith2 = arith2; this.op = op; }
public BoolOperatorInstruction(BoolOperator oper, object a1, object a2, string variable, string variable1, string variable2, bool ifvariable1, bool ifvariable2) { this.oper = oper; this.a1 = a1; this.a2 = a2; this.variable = variable; this.variable1 = variable1; this.variable2 = variable2; this.ifvariable1 = ifvariable1; this.ifvariable2 = ifvariable2; }
public GroupedCondition(BoolOperator theBoolOperator, IBooleanCondition conditionA, IBooleanCondition conditionB) { switch (theBoolOperator) { case BoolOperator._and: this.boolOperator = "and+"; break; case BoolOperator._or: this.boolOperator = "or+"; break; default: break; } this.conditionA = conditionA; this.conditionB = conditionB; }
/// <summary> /// Check if a boolean operation can be shortcut and provide the shorcut if so. /// </summary> /// <param name="current"> The current boolean state </param> /// <param name="operation"> The Operation </param> /// <returns> (If you can use a shortcut, the result of the shortcut) </returns> public static (bool CanShortcut, bool Value) TryShortcut(bool current, BoolOperator operation) { // If either argument of an AND statement is false, or either argument of a NOR statement is true, // the result is always false and we can optimize away evaluation of next if ((operation == BoolOperator.AND && !current) || (operation == BoolOperator.NOR && current)) { return(true, false); } // If either argument of an NAND statement is false, or either argument of an OR statement is // true, the result is always true and we can optimize away evaluation of next if ((operation == BoolOperator.OR && current) || (operation == BoolOperator.NAND && !current)) { return(true, true); } return(false, false); }
public AggregateQuery(BoolOperator op, IEnumerable <IQuery> innerQueries) { this.BoolOperator = op; this.InnerQueries = new List <IQuery>(innerQueries); }
public AggregateQuery(BoolOperator op, IEnumerable<IQuery> innerQueries) { this.BoolOperator = op; this.InnerQueries = new List<IQuery>(innerQueries); }