Skip to content
Snippets Groups Projects
Commit 633102e7 authored by Daniel Agar's avatar Daniel Agar Committed by Lorenz Meier
Browse files

List and ListNode cleanup

parent b70b8288
No related branches found
No related tags found
No related merge requests found
......@@ -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 &);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment