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
template<typename T> | |
class HashSet | |
{ | |
private: | |
using size_t = std::size_t; | |
using hash_function_t = std::function<size_t(const T&)>; | |
static const size_t minimum_capacity = 16; |
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
template<typename T> | |
class HashSet | |
{ | |
private: | |
struct Node | |
{ | |
Node(const T& t = T(), | |
Node* following = nullptr, | |
Node* prev = nullptr) |
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
template<typename Key, typename Value> | |
class HashMap | |
{ | |
private: | |
struct Node | |
{ | |
Node(const Key& k = Key(), | |
const Value& v = Value(), | |
Node* following = nullptr, |
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
template<typename Key, typename Value> | |
class HashMap | |
{ | |
private: | |
struct Node | |
{ | |
Node(const Key& k = Key(), | |
const Value& v = Value(), | |
Node* following = nullptr, |
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
template<typename Key, typename Value> | |
class HashMap2 | |
{ | |
public: | |
using size_t = std::size_t; | |
using hash_function_t = std::function<size_t(const Key& key)>; | |
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
template<typename Key, typename Value> | |
class HashMap2 | |
{ | |
public: | |
using size_t = std::size_t; | |
using hash_function_t = std::function<size_t(const Key& key)>; | |
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
namespace print | |
{ | |
std::string final = "\n"; | |
std::string delimiter = ", "; | |
void booleans() | |
{ | |
std::cout << std::boolalpha; | |
} |
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
template<typename Key, typename Value> | |
class Table | |
{ | |
public: | |
using size_t = std::size_t; | |
struct Item | |
{ | |
using hashes_t = std::pair<size_t, size_t>; |
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
template<typename Key, typename Value> | |
class Table | |
{ | |
public: | |
using size_t = std::size_t; | |
struct Item | |
{ | |
using hashes_t = std::pair<size_t, size_t>; |
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
template<std::size_t N> | |
void rotate_out_of_place(std::size_t (&matrix) [N][N]) | |
{ | |
std::size_t copy [N][N]; | |
for (std::size_t i = 0, end = N/2; i < end; ++i) | |
{ | |
for (std::size_t j = 0; j < N; ++j) | |
{ | |
copy[i][j] = matrix[j][N - 1]; |