Skip to content

Instantly share code, notes, and snippets.

View msmoiz's full-sized avatar

Mustafa S. Moiz msmoiz

View GitHub Profile
@msmoiz
msmoiz / CMakeLists.txt
Last active June 22, 2021 16:39
CMake Debug Settings with Visual Studio
cmake_minimum_required(VERSION 3.19)
project(foo)
add_executable(foo src/main.cpp)
set_target_properties(foo PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
VS_DEBUGGER_COMMAND_ARGUMENTS "bar.txt")
@msmoiz
msmoiz / quick-sort.h
Created June 9, 2021 23:47
Quick Sort
#include <vector>
using std::vector;
template<typename T>
void exchange(vector<T>& list, int i, int j)
{
T temp = list[i];
list[i] = list[j];
list[j] = temp;
#include <vector>
template<typename T>
void exchange(vector<T>& list, int i, int j)
{
T temp = list[i];
list[i] = list[j];
list[j] = temp;
}
template<typename T>
void exchange(vector<T>& list, int i, int j)
{
T temp = list[i];
list[i] = list[j];
list[j] = temp;
}
/**
* Part of the drawback of the insertion sort
@msmoiz
msmoiz / insertion-sort.h
Last active June 2, 2021 21:07
Insertion Sort
#include <vector>
template<typename T>
void exchange(vector<T>& list, int i, int j)
{
T temp = list[i];
list[i] = list[j];
list[j] = temp;
}
@msmoiz
msmoiz / selection-sort.h
Last active June 1, 2021 18:22
Selection Sort
template<typename T>
void exchange(Vector<T>& list, int i, int j)
{
T temp = list[i];
list[i] = list[j];
list[j] = temp;
}
/**
* In a typical selection sort (a simple, but inefficient
@msmoiz
msmoiz / client.cpp
Last active May 23, 2021 22:53
Using Union-Find to Trace Connections in C++
#include <iostream>
#include "unionfind.h"
int main(int argc, const char* argv[])
{
int node_count;
std::cin >> node_count;
std::cout << "Size: " << node_count << std::endl;
@msmoiz
msmoiz / client.cpp
Last active May 21, 2021 23:33
Implementing a Queue Using a Linked List in C++
#include <iostream>
#include <string>
#include "queue.h"
int main()
{
Queue<std::string> orders;
orders.enqueue("burger");
orders.enqueue("fries");
@msmoiz
msmoiz / client.cpp
Created May 20, 2021 19:19
Implementing a Stack Using a Dynamic Array in C++
#include <string>
#include "stack.h"
int main()
{
Stack<std::string> notes;
notes.push("Hey");
notes.push("what's");
notes.push("up.");
@msmoiz
msmoiz / main.cpp
Created April 13, 2021 01:29
Source and header files accompanying the Unrealistic.dev post on complex C++ compilation from the command line.
#include "static.h"
#include "shared.h"
#include <iostream>
void local_hello()
{
std::cout << "Hello local world!" << std::endl;
}
int main()