/
thomas-king
/
IntegerParser
Обзор
Документация
Войти
/
thomas-king
/
IntegerParser
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
include/lib/ListNode.h
63 строки
1 KB
AceRodstin
Add support for hexadecimal integers.
02 янв 2023, 11:42
02 янв 2023, 11:42
8f1dda5
Код
Авторство
О чём код?
// // ListNode.h // Libraries // // Created by Ace Rodstin on 30 Dec 2022. // #ifndef LISTNODE_HEADER_FILE #define LISTNODE_HEADER_FILE #include <memory> using namespace std; template<class T> struct ListNode { public: unique_ptr<ListNode> next; T value; ListNode(unique_ptr<ListNode> next, T value) { this->next = move(next); this->value = value; }; T back() { if (next) { return next->back(); } else { return value; } } void push_back(T value) { end().next = make_unique<ListNode>(nullptr, value); } void push_back(unique_ptr<ListNode>& next) { end().next = move(next); } template<class C> void for_each(C closure) { closure(this->value); if (next != nullptr) { next->for_each(closure); } } private: ListNode& end() { if (next) { return next->end(); } else { return *this; } } }; #endif