Package org.cloudbus.cloudsim.util
Class Util
java.lang.Object
org.cloudbus.cloudsim.util.Util
A class with general purpose utilities.
- Since:
- CloudSim Plus 6.0.0
- Author:
- Manoel Campos da Silva Filho
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[][]
newSquareMatrix
(int size) Creates a square matrix with a given sizestatic double[][]
newSquareMatrix
(int size, double defaultValue) Creates a square matrix with a given sizestatic void
printProgress
(int current, int total) Prints a progress bar at the command line for any general process represented by several tasks (steps).static void
printProgress
(int current, int total, boolean progressBarInNewLine) Prints a progress bar at the command line for any general process represented by several tasks (steps).static void
sleep
(long millis) Makes the current thread to sleep for a given amount ot milliseconds.
-
Method Details
-
sleep
public static void sleep(long millis) Makes the current thread to sleep for a given amount ot milliseconds.- Parameters:
millis
- the time to sleep in milliseconds
-
printProgress
public static void printProgress(int current, int total) Prints a progress bar at the command line for any general process represented by several tasks (steps). The bar is updated at the current line. If nothing is printed between updates, the bar is shown at the same place. You can use it like the sample below:final int total = 100; for (int i = 0; i <= total; i++) { Util.sleep(120); //simulates some task (use your own code here) Util.printProgress(i, total); }
- Parameters:
current
- the index of the current finished task (step)total
- the total number of tasks (steps)- See Also:
-
printProgress
public static void printProgress(int current, int total, boolean progressBarInNewLine) Prints a progress bar at the command line for any general process represented by several tasks (steps). You can use it like the sample below:final int total = 100; for (int i = 0; i <= total; i++) { Util.sleep(120); //simulates some task (use your own code here) Util.printProgress(i, total); }
- Parameters:
current
- the index of the current finished task (step)total
- the total number of tasks (steps)progressBarInNewLine
- indicates if the progress bar will be printed in a new line or not- See Also:
-
newSquareMatrix
public static double[][] newSquareMatrix(int size) Creates a square matrix with a given size- Parameters:
size
- the matrix size, defining the number of columns and rows- Returns:
- the new square matrix
-
newSquareMatrix
public static double[][] newSquareMatrix(int size, double defaultValue) Creates a square matrix with a given size- Parameters:
size
- the matrix size, defining the number of columns and rowsdefaultValue
- default value for all matrix positions.- Returns:
- the new square matrix
-