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 <vector> | |
#include <algorithm> | |
template <class Iter> | |
Iter consecutive_find(Iter first, Iter last, std::size_t n) | |
{ | |
Iter marker(first), lead(first); | |
std::size_t count(1); |
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 <stdexcept> | |
// uses the Array<T> class | |
template <class T> | |
class Array2D | |
{ | |
protected: | |
unsigned int numberOfRows, numberOfColumns; | |
Array<T> array; | |
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 <stdexcept> | |
template <class T> | |
class Array | |
{ | |
public: | |
Array(); | |
Array(unsigned int, unsigned int = 0); | |
Array(Array const&); | |
~Array(); |
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 <stdexcept> | |
template <class T> | |
class LinkedList; | |
template <class T> | |
class ListElement | |
{ | |
friend LinkedList<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
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
#include <fstream> | |
class insertbuf : public std::streambuf | |
{ | |
public: | |
insertbuf(std::ostream& os, std::string const& data) | |
: m_stream(os) |
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> | |
class Node | |
{ | |
public: | |
Node(int data, Node* left = nullptr, Node* right = nullptr) | |
: data(data) | |
, left(left) | |
, right(right) | |
{ } |
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
Node* DeleteNode(Node*& head, int value) | |
{ | |
Node** ptr = &head, *next; | |
while (*ptr && (*ptr)->data != value) | |
ptr = &(*ptr)->next; | |
if (!*ptr) | |
return NULL; | |
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> | |
template <class T> | |
class circular_linked_list | |
{ | |
struct node; | |
node* tail{nullptr}, **back_ptr{&tail}, **front_ptr{nullptr}; | |
int m_size{0}; | |
template <class U> |
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 <sstream> | |
#include <iostream> | |
template<typename Tag, typename Tag::type M> | |
struct grant_access | |
{ | |
friend typename Tag::type get(Tag) { return M; } | |
}; | |
template<class cT, long n> |
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 <initializer_list> | |
#include <stdexcept> | |
template <class T> | |
class list; | |
template <class T> | |
class Node | |
{ |