Package jromp.parallel.var
Class Variables
java.lang.Object
jromp.parallel.var.Variables
Represents a collection of variables.
-
Method Summary
Modifier and TypeMethodDescription<T extends Serializable>
VariablesAdds a variable with the specified name to the map of variables.boolean
Checks if the variable map contains a variable with the specified name.copy()
Creates a copy of the Variables object.static Variables
create()
Creates a new instance of the Variables class.static Variables
Creates a new instance of the Variables class with the provided variable map.void
end()
Ends all variables in the variable map.<T extends Serializable>
Variable<T> Retrieves the variable with the specified name from the Variables object.getVariablesOfType
(Class<T> type) Retrieves a list of variables of a specified type.boolean
isEmpty()
Checks if the variable map is empty.int
size()
Returns the size of the map of variables.toString()
Returns a string representation of the Variables object.
-
Method Details
-
create
Creates a new instance of the Variables class.- Returns:
- the newly created Variables object.
-
create
Creates a new instance of the Variables class with the provided variable map.- Parameters:
varMap
- the map of variables to be added to the new instance.- Returns:
- the newly created Variables object.
-
add
Adds a variable with the specified name to the map of variables.- Type Parameters:
T
- the type of the variable.- Parameters:
name
- the name of the variable.variable
- the variable to be added.- Returns:
- the updated Variables object.
-
get
Retrieves the variable with the specified name from the Variables object.- Type Parameters:
T
- the type of the variable.- Parameters:
name
- the name of the variable to retrieve.- Returns:
- the variable with the specified name, or null if it does not exist.
-
isEmpty
public boolean isEmpty()Checks if the variable map is empty.- Returns:
true
if the variable map is empty,false
otherwise.
-
size
public int size()Returns the size of the map of variables.- Returns:
- the size of the map of variables.
-
contains
Checks if the variable map contains a variable with the specified name.- Parameters:
name
- the name of the variable to check.- Returns:
true
if the variable map contains a variable with the specified name,false
otherwise.
-
toString
Returns a string representation of the Variables object. The string contains all the variables in the variable map, formatted as"name -> variableString\n"
. If the variable map is empty, the string "No variables" is returned. -
copy
Creates a copy of the Variables object.- Returns:
- a copy of the Variables object.
-
getVariablesOfType
Retrieves a list of variables of a specified type.- Type Parameters:
T
- the type of the variables.- Parameters:
type
- the Class object representing the type of variables to retrieve.- Returns:
- a list of variables of the specified type.
-
end
public void end()Ends all variables in the variable map.
-