This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS | |
#include <sys/types.h> | |
#include <algorithm> | |
#include <atomic> | |
#include <chrono> | |
#include <iostream> | |
#include <ostream> | |
#include <ratio> | |
#include <semaphore> | |
#include <sstream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
/** | |
* @brief Compute the length of a string (number of bytes before \0) | |
* | |
*/ | |
int getStrlen(const char *str) { | |
// library function: | |
// return strlen(str); | |
int length = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <functional> | |
template <typename Key, typename Value> | |
struct TimedMap { | |
using clock = std::chrono::steady_clock; | |
using time_point = clock::time_point; | |
using callback = std::function<void (const Key &key, const Value &value)>; | |
TimedMap(int concurrencyLimit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mutex> | |
#include <vector> | |
#include <thread> | |
#include <condition_variable> | |
/// Size of the render target in console characters | |
const int WIDTH = 100; | |
const int HEIGHT = 30; | |
/// Render target, render threads write next frame here | |
/// 1 extra in width for terminating '\0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if _WIN64 | |
#define _CRT_SECURE_NO_WARNINGS | |
#endif | |
#include <cstdlib> | |
#include <algorithm> | |
#include <random> | |
#include <cassert> | |
#include <cstdio> | |
#include <cstring> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unordered_map> | |
struct NamedArguments { | |
enum class Name { | |
start, step, stop | |
}; | |
struct BaseArg { | |
Name name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void printNumbers(/*TODO:*/) { | |
/*TODO:*/ | |
for (int c = start; c < stop; c += step) { | |
std::cout << c << ' '; | |
} | |
std::cout << std::endl; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cctype> | |
#include <cstring> | |
#include <iostream> | |
typedef int (*Validator)(int); | |
bool isValidRegistration(char reg[9]) { | |
const Validator validators[9] = {isupper, isupper, isdigit, isdigit, isdigit, isdigit, isupper, isupper }; | |
const int len = strlen(reg); | |
const Validator *check = len == 8 ? validators : validators + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
typedef unsigned char pixel[3]; | |
typedef pixel** Image; | |
/// Typedef for fully const pixel array to avoid long type | |
typedef const pixel * const* const ConstImage; | |
/// 2D matrix of booleans, used to mark pixels as visited | |
typedef bool** BoolMatrix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template <typename T> | |
struct ScopedPointer { | |
private: | |
T *ptr; | |
public: | |
ScopedPointer(const ScopedPointer &) = delete; | |
ScopedPointer &operator=(const ScopedPointer &) = delete; |
NewerOlder