#ifndef LINKEDINTLIST_H_
#define LINKEDINTLIST_H_
#include <memory>
#include "IntList.h"
namespace intlist333 {
class LinkedIntList : public IntList {
public:
LinkedIntList() = default;
LinkedIntList(const LinkedIntList& other) = delete;
LinkedIntList& operator=(const LinkedIntList& other) = delete;
~LinkedIntList() override = default;
int num_elements() const override { return num_elements_; }
void Push(int payload) override;
void Append(int payload) override;
bool Pop(int* const payload_ptr) override;
bool Slice(int* const payload_ptr) override;
private:
struct Node {
int payload;
std::shared_ptr<Node> next;
std::weak_ptr<Node> prev;
};
int num_elements_ = 0;
std::shared_ptr<Node> head_;
std::weak_ptr<Node> tail_;
};
}
#endif