Enum BoolOp

    • Enum Constant Detail

      • AND

        public static final BoolOp AND
        Conjunction. This operation has arity 2.
      • OR

        public static final BoolOp OR
        Disjunction. This operation has arity 2.
      • NOT

        public static final BoolOp NOT
        Negation. This operation has arity 1.
      • IMP

        public static final BoolOp IMP
        Implication. This operation has arity 2.
      • XOR

        public static final BoolOp XOR
        Exclusive or. This operation has arity 2.
      • EQU

        public static final BoolOp EQU
        Equivalence. This operation has arity 2.
    • Method Detail

      • values

        public static BoolOp[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (BoolOp c : BoolOp.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static BoolOp valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • arity

        public int arity()
        Description copied from interface: Op
        Return the arity of the operation function. If the arity is zero, the operation is terminal operation.
        Specified by:
        arity in interface Op<Boolean>
        Returns:
        the arity of the operation
      • eval

        public boolean eval​(boolean... args)
        Evaluates the operation with the given arguments.
        Parameters:
        args - the operation arguments
        Returns:
        the evaluated operation
        See Also:
        apply(Boolean[])
      • toBoolOp

        public static Op<BooleantoBoolOp​(String string)
        Converts the string representation of an operation to the operation object. It is used for converting the string representation of a tree to an operation tree. If you use it that way, you should not forget to re-index the tree variables.
        final TreeNode<Op<Boolean>> tree = TreeNode.parse( "and(or(x,y),not(y))", BoolOp::toBoolOp ); assert Program.eval(tree, false, false) == false; Var.reindex(tree); assert Program.eval(tree, false, false) == true;
        Parameters:
        string - the string representation of an operation which should be converted
        Returns:
        the operation, converted from the given string
        Throws:
        IllegalArgumentException - if the given value doesn't represent a mathematical expression
        NullPointerException - if the given string value is null
        Since:
        5.0
        See Also:
        Var.reindex(TreeNode), Program.eval(Tree, Object[])