Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef DYNAMICSTRUCTURES_LIST_H
- #define DYNAMICSTRUCTURES_LIST_H
- #include <iostream>
- #define THROW_OUT_OF_RANGE_EXCEPTION throw std::exception("Attempt to access an element out of range")
- template <typename T>
- class List
- {
- private:
- struct Node
- {
- T value;
- Node* next;
- Node* prev;
- Node(const T& value, Node* next, Node* prev) : value(value), next(next), prev(prev) {};
- };
- Node* first_;
- Node* last_;
- size_t size_;
- public:
- List();
- explicit List(const size_t count);
- explicit List(const size_t count, const T& value);
- void resize(const size_t count);
- void resize(const size_t count, const T& value);
- void pushFront(const T& value);
- void popFront();
- void pushBack(const T& value);
- void popBack();
- void insertAfter(const size_t id, const T& value);
- void eraseAfter(const size_t id);
- void clear();
- _NODISCARD size_t size() const;
- _NODISCARD bool empty() const;
- T& operator[](const size_t id);
- };
- #include "List.tpp"
- #endif //DYNAMICSTRUCTURES_LIST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement