Day 4 - A lot of changes
So.. It’s been a while.. (again) Unfortunately I started doing other personal things and forgot about this project but I still kept doing small fixes. In fact, I had a 12 day streak but unfortunately I lost it lol. Anyway.. yesterday I finally locked in again and finished what I needed to do!
New algorithm!
I finally added the Selection sort algorithm! It was a bit harder compared to the bubble sort cause I had some problems while porting it in this new style. Another reason is because of all the refactoring I did of the main code that I’m just about to introduce! ## Splitting files! Like I said in the beginning, this project is a way for me to get better at coding, learn sorting algorithms and even learn new approaches into coding that I haven’t learned at school! For this reason, I decided to learn more about header files and how to split the code on multiple files instead of having just one big .cpp file! As of now, the structure look like this!
VisualSort/
├── images/
│ └── image1.png
├── src/
│ ├── algorithms/
│ │ ├── bubbleSort.h
│ │ └── selectionSort.h
│ ├── main.cpp
│ └── main.h
├── .gitignore
├── CMakeLists.txt
└── README.md
So now I have the main.h for all the variables needed for the sorting algorithms and the main GUI to function.
Then, I have a folder called algorithms where I have all the header files of the algorithms I implemented! (I know that I should make a .h and .cpp file and that the header is only for declaration but I didn’t want to add more files since it’s a simple project).
Speed slider!
Now, I even added a slider bar to let the user choose the speed of the sorting algorithm! The slider changes the seconds of the delay between every step of the algorithm and it goes from a minimum of 0.1 sec (fastest) and a maximum of 2.0 (slowest).
Next features…
After all of this I think I’m gonna add atleast 1 or 2 new algorithms, a box to show a quick description of the algorithm and then some stats about the like:
- Array accesses
- Comparisons performed
- Swaps performed
(Of course the data will be equal to a normal implementation of the algorithm and not according to my way of implementation.)
Something first..
If you ask why I took 4h 36min to implement ONLY these features it’s because I’m not really quick at coding and everytime I tried to implement the Selection sort I always had problems.. and other than that I even had to refactor all the code to divide it into files unfortunately.
Anyway, that’s all and see you in the next devlog! Hoping that it will be soon. If I lock in it should be tomorrow maybe or I don’t know. Before saying goodbye, here’s a quick screenshot of how the software looks now!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.