Enum VarUsage

  • All Implemented Interfaces:
    Serializable, Comparable<VarUsage>

    public enum VarUsage
    extends Enum<VarUsage>
    A tri-state encoding the number of usages of a variable or context reference.
    Author:
    BaseX Team 2005-23, BSD License, Leo Woerteler
    • Enum Constant Detail

      • NEVER

        public static final VarUsage NEVER
        No usages.
      • ONCE

        public static final VarUsage ONCE
        Exactly one usage.
      • MORE_THAN_ONCE

        public static final VarUsage MORE_THAN_ONCE
        More than one usage.
    • Method Detail

      • values

        public static VarUsage[] 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 (VarUsage c : VarUsage.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static VarUsage 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
      • max

        public VarUsage max​(VarUsage other)
        Combines the usages for two alternative branches.
        Parameters:
        other - usage count to be combined
        Returns:
        number of usages for the disjunction of both branches
      • plus

        public VarUsage plus​(VarUsage other)
        Combines the usages for two expressions that are both executed.
        Parameters:
        other - usage count to be combined
        Returns:
        number of usages of both expressions combined
      • times

        public VarUsage times​(long count)
        Number of usages if the code is executed count times.
        Parameters:
        count - number of executions, may be -1 if not known
        Returns:
        number of usages
      • sum

        public static VarUsage sum​(Var var,
                                   Expr... exprs)
        Checks how often a variable or context reference is accessed in all given expressions.
        Parameters:
        var - variable (Var reference) or context (null) to inline
        exprs - expressions
        Returns:
        number of accesses to the variable in all expressions combined
      • maximum

        public static VarUsage maximum​(Var var,
                                       Expr... exprs)
        Checks how often a variable or context reference is used in any of the given expressions.
        Parameters:
        var - variable (Var reference) or context (null) to inline
        exprs - expressions
        Returns:
        maximum number of accesses in any given expression