-
Notifications
You must be signed in to change notification settings - Fork 12
Code structure
The source code it's easy to understand and lightweight! Here you'll find a summary about how the project is structured, but every .cpp
file contains comments and explanations of each functions. All the source code is located in the /src
directory.
If you want to add a new sorting algorithm here you can find a wiki page that explains that without needing to understand the whole code base. Let's dive in!
-
main.cpp
: Main function, manages the keypress events and draws the content on screen. -
SortController.h / SortController.cpp
: Class to manage the vector to be sorted and the methods related to it. -
Sortable.h / Sortable.cpp
: Class to create the objects that will compose the sort vector (managed bySortController
). -
SortAlgorithms.h / SortAlgorithms.cpp
: Sorting algorithms functions. -
Utils.h / Utils.cpp
: Utility functions.
The visualizer moves everything related to sorting into a different thread, that way the main process only takes care of drawing the contents and the actual sorting runs smooth without waiting every frame to be drawn.
The sorting thread is defined in SortController.h
, and is called from SortController::startSort()
.
Also, the final animation (the array turning green), is made in a separated thread defined also in SortController.h
, just to prevent the animation from blocking when the sorting array is joined. If this is confusing don't worry about this, it's just made in that way to prevent a little animation bug.