mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-25 16:56:25 +08:00
List and ListNode cleanup
This commit is contained in:
committed by
Lorenz Meier
parent
b70b8288b9
commit
633102e7ca
@@ -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 &);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user