This is my Capstone Project for the Udacity C++ Nanodegree. After launching the program you can choose (with your mouse) between Merge Sort, QuickSort, and Bubble Sort. When the sorting is done, you can generate a new array and pick another algorithm. To exit, press ESC.
button.h/button.cpp
: Contains a class Button that is responsible for creating places in the screen where it is responsive to clicks.
layout.h/layout.cpp
: Contains a class Layout that was written with the goal of easy portability. You can place it in a SDL application and add text to it with ease. Here, it display the sorting algorithm names and the project name.
quickSort.h/mergeSort.h
: Contains both the functions that operate in the array and the functions that are responsible for the update of the screen and display of the sorting algorithm.
main.h/main.cpp
: Contains the initialization of SDL and SDL_TFF. The text and buttons are inicialized afterwards. The first loop keeps checking for input of the user (through the buttons in the screen and keys) and a second loop is started only if the user choose a sorting algorithm and inicialize it. A condition variable is then used with a mutex to restrict changes in the array until the end of the sorting.
Dependencies for Running Locally (extended from here)
- cmake >= 3.7
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- SDL2 >= 2.0
- All installation instructions can be found here
- Note that for Linux, an
apt
orapt-get
installation is preferred to building from source.
- SDL2_ttf >= 2.0
- All installation instructions can be found here (ubuntu) or here (from source)
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./Visualizer
.
- Rightwards arrow ( → ) increments array size
- Leftwards arrow ( ← ) decrements array size