Class FunctionManager

java.lang.Object
com.github.gbenroscience.util.FunctionManager

public class FunctionManager extends Object
Author:
JIBOYE OLUWAGBEMIRO OLAOLUWA
  • Field Details

    • ANON_PREFIX

      public static final String ANON_PREFIX
      See Also:
    • ANON_CURSOR

      public static final AtomicInteger ANON_CURSOR
      This is an indicator of the total number of anonymous functions ever created since the code was run in this session.
    • FUNCTIONS

      public static final Map<String,Function> FUNCTIONS
  • Constructor Details

    • FunctionManager

      public FunctionManager()
  • Method Details

    • containsAlgebraicFunction

      public static boolean containsAlgebraicFunction(String fName)
      Parameters:
      fName - The name of the dependent variable of the function or the full name of the function which is a combination of the name of its dependent variable and its independent variables enclosed in circular parentheses. e.g in y = x^3, either y or y(x) may be supplied.
      Returns:
      true if a Function exists by the name supplied, but it is not a matrix
    • containsMatrix

      public static boolean containsMatrix(String fName)
      Parameters:
      fName -
      Returns:
      true if the function exists and it is matrix type
    • containsAny

      public static boolean containsAny(String fName)
      Parameters:
      fName -
      Returns:
      true if the function exists and is either Matrix or Algebraic
    • getFunction

      public static Function getFunction(String fName)
      Parameters:
      fName - The name of the dependent variable of the function.
      Returns:
      the Function object that has the name supplied if it exists. If no such Function object exists, then it returns null.
    • lookUp

      public static Function lookUp(String functionName)
      Attempts to retrieve a Function object from a FunctionManager based on its name.
      Parameters:
      functionName - The name of the Function object.
      Returns:
      the Function object that has that name or null if the Function is not found.
    • lockDown

      public static Function lockDown(String fName, String... independentVars)
      Some actions require a handle being gotten on a function name. This method allows you to acquire the name. Create a dummy function to be populated with its true values later.
      Parameters:
      fName -
      independentVars -
      Returns:
    • lockDownAnon

      public static Function lockDownAnon(String... independentVars)
      Create a dummy function to be populated with its true values later.
      Parameters:
      independentVars -
      Returns:
    • lockDownAnon

      public static Function lockDownAnon(Function f)
      Creates the anonymous copy of a Function
      Parameters:
      f -
      Returns:
    • add

      public static Function add(String expression)
      Adds a Function object to this FunctionManager.
      Parameters:
      expression - The expression that creates the Function to add. The form is:F=@(x,y,z,...)mathexpr. e.g y=@(x)3x-x^2; Functions take precedence over variables.. so if a function called sin_func is created and there exists a variable with that name, the system discards that variable
    • add

      public static Function add(Function f)
      Parameters:
      f - The Function object to add to this object.
    • load

      public static void load(Map<String,Function> functions)
      Loads the Function objects in this Map into the FUNCTIONS Map.
      Parameters:
      functions - A Map of Function objects.
    • load

      public static void load(Map<String,Function> functions, boolean clearFirst)
      Loads the Function objects in this Map into the FUNCTIONS Map.
      Parameters:
      functions - A Map of Function objects.
      clearFirst - If true, then the FUNCTIONS is cleared first before new content is loaded into it.
    • delete

      public static void delete(String fName)
      Removes a Function object from this FunctionManager.
      Parameters:
      fName -
    • update

      public static void update(String oldFuncName, String newName)
      Used to update Functions by name. A great use is to promote anonymous functions into named functions
      Parameters:
      oldFuncName -
      newName -
    • update

      public static void update(Function f)
      Updates the Map with the most recent version of this Function.
      Parameters:
      f -
    • clearAnonymousFunctions

      public static void clearAnonymousFunctions()
      Deletes all anonymous functions
    • clear

      public static final void clear()
    • countAnonymousFunctions

      public static int countAnonymousFunctions()
      Returns:
      the number of anonymous functions in the FunctionManager.
    • getDefinedFunctions

      public static final ArrayList<Function> getDefinedFunctions()
      Returns:
      An ArrayList of all non-anonymous functions.
    • update

      public static void update()
      Saves stored functions and: updates the client UIs that use this manager.
    • initializeFunctionVars

      public static void initializeFunctionVars()
      Registers the parameters of all registered functions as Variables on the Variable Registry.
    • main

      public static void main(String[] args)