List and ListNode cleanup

This commit is contained in:
Daniel Agar
2017-08-17 09:50:33 -04:00
committed by Lorenz Meier
parent b70b8288b9
commit 633102e7ca
+24 -26
View File
@@ -43,45 +43,43 @@ template<class T>
class __EXPORT ListNode
{
public:
ListNode() : _sibling(nullptr)
{
}
virtual ~ListNode() {};
ListNode() : _sibling() {}
virtual ~ListNode() = default;
// no copy, assignment, move, move assignment
ListNode(const ListNode &) = delete;
ListNode &operator=(const ListNode &) = delete;
ListNode(ListNode &&) = delete;
ListNode &operator=(ListNode &&) = delete;
void setSibling(T sibling) { _sibling = sibling; }
T getSibling() { return _sibling; }
T get()
{
return _sibling;
}
const T getSibling() { return _sibling; }
protected:
T _sibling;
private:
// forbid copy
ListNode(const ListNode &other);
// forbid assignment
ListNode &operator = (const ListNode &);
};
template<class T>
class __EXPORT List
{
public:
List() : _head()
{
}
virtual ~List() {};
List() : _head() {}
virtual ~List() = default;
// no copy, assignment, move, move assignment
List(const List &) = delete;
List &operator=(const List &) = delete;
List(List &&) = delete;
List &operator=(List &&) = delete;
void add(T newNode)
{
newNode->setSibling(getHead());
setHead(newNode);
_head = newNode;
}
T getHead() { return _head; }
const T getHead() { return _head; }
protected:
void setHead(T &head) { _head = head; }
T _head;
private:
// forbid copy
List(const List &other);
// forbid assignment
List &operator = (const List &);
};