ALGO-VISUALIZER DOCUMENTATION π₯ο
Below is the documentation for the algo-visualizer project. The project is a tool to visualize the execution of algorithms, specifically sorting algorithms. The visualizer is written in C++ and uses the SFML library for rendering.
visualizer Namespaceο
This is the documentation for the classes and functions in the visualizer namespace.
-
namespace visualizerο
Enums
-
enum AppStateο
Enum class to represent the different states of the application.
WELCOME_SCREEN: The screen that is displayed when the application is started SELECTION_SCREEN: The screen that is displayed when the user selects the sorting algorithm RUNNING: The screen that displays the sorting process COMPLETION: The screen that is displayed when the sorting process is complete EXIT: The state that is reached when the application is closed
Values:
-
enumerator WELCOME_SCREENο
-
enumerator SELECTION_SCREENο
-
enumerator RUNNINGο
-
enumerator COMPLETIONο
-
enumerator EXITο
-
enumerator WELCOME_SCREENο
-
class SortVisualizer : public visualizer::Visualizer<std::vector<int>>ο
- #include <visualizer.h>
Class for visualizing sorting algorithms.
Note
Inherits from the Visualizer class
Public Functions
-
SortVisualizer(int width, int height, int size, int speed)ο
Construct a new Sort Visualizer object.
- Parameters:
width β The width of the window
height β The height of the window
size β The size of the array to sort
speed β The speed of the visualization
-
SortVisualizer(int width, int height, int size, int speed, std::string heading)ο
Construct a new Sort Visualizer object.
- Parameters:
width β The width of the window
height β The height of the window
size β The size of the array to sort
speed β The speed of the visualization
heading β The heading of the window
-
SortVisualizer(int width, int height, int size, int speed, std::string heading, std::string timeComplexity)ο
Construct a new Sort Visualizer object.
- Parameters:
width β The width of the window
height β The height of the window
size β The size of the array to sort
speed β The speed of the visualization
heading β The heading of the window
timeComplexity β The time complexity of the algorithm
-
virtual void addState(const std::vector<int> &array) overrideο
Add a new state (array configuration) to be visualized.
Note
Overrides the addState method of the Visualizer class
- Parameters:
array β The array to add
- Returns:
void
-
virtual void visualize() overrideο
Visualize the algorithm.
Note
Overrides the visualize method of the Visualizer class
- Returns:
void
-
SortVisualizer(int width, int height, int size, int speed)ο
-
template<typename Container>
class Visualizerο - #include <visualizer.h>
Abstract class for visualizing algorithms.
- Template Parameters:
Container β The type of the data structure to visualize
Public Functions
-
Visualizer(int width, int height, int speed, std::string heading)ο
Construct a new Visualizer object.
- Parameters:
width β The width of the window
height β The height of the window
speed β The speed of the visualization
heading β The heading of the window
-
virtual void addState(const Container &array) = 0ο
Add a new state (array configuration) to be visualized.
Note
Pure virtual function
- Parameters:
array β The array to add
- Returns:
void
-
virtual void visualize() = 0ο
Visualize the algorithm.
Note
Pure virtual function
- Returns:
void
-
enum AppStateο
algorithm Namespaceο
This is the documentation for the classes and functions in the algorithm namespace.
-
namespace algorithmο
Enums
Functions
-
void randomNumberGen(std::vector<int> &arr, int size, int min, int max)ο
-
void selectionSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback =
[](const std::vector< int > &) {})ο Sorts the given array using the selection sort algorithm.
- Parameters:
arr β The array to sort
stepCallback β lambda function to call after each step letting the caller know the current state of the array
-
void bubbleSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback =
[](const std::vector< int > &) {})ο Sorts the given array using the bubble sort algorithm.
- Parameters:
arr β The array to sort
stepCallback β lambda function to call after each step letting the caller know the current state of the array
-
void insertionSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback =
[](const std::vector< int > &) {})ο Sorts the given array using the insertion sort algorithm.
- Parameters:
arr β The array to sort
stepCallback β lambda function to call after each step letting the caller know the current state of the array
-
void iterMergeSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback)ο
-
void iterQuickSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback)ο
-
void mergeSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback =
[](const std::vector< int > &) {})ο Sorts the given array using the merge sort algorithm.
- Parameters:
arr β The array to sort
stepCallback β lambda function to call after each step letting the caller know the current state of the array
-
void quickSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback =
[](const std::vector< int > &) {})ο Sorts the given array using the quick sort algorithm.
- Parameters:
arr β The array to sort
stepCallback β lambda function to call after each step letting the caller know the current state of the array
-
void bogoSort(std::vector<int> &arr, std::function<void(const std::vector<int>&)> stepCallback =
[](const std::vector< int > &) {})ο Sorts the given array using the bogo sort algorithm.
Note
This algorithm wonβt work for large arrays as the time complexity is infinity in the worst case. For the application of this visualizer, it will not work as the sorting is recquired to be finished before visualizing the steps.
- Parameters:
arr β The array to sort
stepCallback β lambda function to call after each step letting the caller know the current state of the array
-
void randomNumberGen(std::vector<int> &arr, int size, int min, int max)ο
algo_resources Namespaceο
This is the documentation for the classes and functions in the algo_resources namespace.
Warning
doxygennamespace: Cannot find namespace βalgo_resourcesβ in doxygen xml output for project βALGO-VISUALIZERβ from directory: /home/docs/checkouts/readthedocs.org/user_builds/algo-visualizer/checkouts/latest/docs/source/../../build/docs/doxygen/xml