-
Notifications
You must be signed in to change notification settings - Fork 13
Code structure
alesbe edited this page Apr 20, 2022
·
6 revisions
The source code it's easy to understand and lightweight, but I'll explain in detail each part of the project in case that you want to contribute!
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!
I'll explain what each file does before going into details. At this moment, each file contains a header file (ended .h), containing the declarations, and another file (ended .cpp), containing the definitions.
-
main.cpp
: Main function and the main loop. -
SortController.h / SortController.cpp
: Class to manage the vector that will be sorted and the methods related to it. -
Sortable.h / Sortable.cpp
: Class to create the objects that will be inside the sorting array. -
SortAlgorithms.h / SortAlgorithms.cpp
: Sorting algorithms. -
Utils.h / Utils.cpp
: Utility functions.
This is the main project structure, as you can see, it's relatively small, if you want to know more details, take a look at the next part!
We could explain this file easlily with pseudo-code:
#defines
#includes
int main() {
create_window();
[variables that will be configured by user like number of elements or time between iterations]
[initialize SortController and populate array with default values]
// Main loop
while(windowIsOpen()){
//
// Check for events (keypress, window closed, etc)
//
// Clear window
//
// Draw / display sorting vector
//
}
}
🚧 Wiki page not finished, come back later! 🚧