This file contains hidden or 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 <utility> | |
class SinglyLinkedList | |
{ | |
public: | |
SinglyLinkedList() = default; | |
SinglyLinkedList(const SinglyLinkedList& that) | |
{ | |
if (Node* that_c = that.head) | |
{ |
This file contains hidden or 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 <thread> | |
#include <atomic> | |
#include <functional> | |
#include <vector> | |
#include "threadsafe_queue" | |
class join_threads | |
{ | |
public: |
This file contains hidden or 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 <queue> | |
#include <mutex> | |
#include <memory> | |
#include <condition_variable> | |
template<class T> | |
class threadsafe_queue | |
{ | |
public: | |
threadsafe_queue() {} |
This file contains hidden or 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 <atomic> | |
class spinlock_mutex | |
{ | |
spinlock_mutex() : m_flag(ATOMIC_FLAG_INIT) {} | |
void lock() | |
{ | |
// Function returns true if flag was set before the call and false otherwice. | |
while(m_flag.test_and_set(std::memory_order_acquire)); |
This file contains hidden or 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 <exception> | |
#include <stack> | |
#include <mutex> | |
#include <memory> | |
struct empty_stack : std::exception | |
{ | |
const char* what() const noexcept override; | |
}; |
This file contains hidden or 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 <exception> | |
#include <stack> | |
#include <mutex> | |
#include <memory> | |
struct empty_stack : std::exception | |
{ | |
const char* what() const noexcept; | |
}; |
This file contains hidden or 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> | |
#include <bitset> | |
struct bitarr | |
{ | |
bitarr(unsigned char v) : val(v) {} | |
void print() | |
{ | |
std::bitset<8 * sizeof(unsigned char)> bits(val); |
This file contains hidden or 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> | |
#include <string> | |
#include <functional> | |
template <class T> | |
inline void hash_combined(std::size_t& res, const T& val) | |
{ | |
std::hash<T> h; | |
res ^= h(val) + 0x9e3779b9 + (res << 6) + (res >> 2); | |
} |
This file contains hidden or 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
class Str | |
{ | |
public: | |
Str(); | |
Str(const char* src); | |
~Str(); | |
Str(const Str& that); | |
Str& operator= (const Str& that); |
This file contains hidden or 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> | |
int n = 0; | |
int m = 0; | |
int* arr; | |
void increse(int index) | |
{ | |
if (!(index < n)) |
NewerOlder