From 1537bb705bc7952fe8a0c94cacc9c434cba8d23d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 22 Nov 2021 05:52:49 +0000 Subject: (list)~NULL -> nullptr C++ styling. --- list.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/list.cpp b/list.cpp index 5dc6d18..83e7068 100644 --- a/list.cpp +++ b/list.cpp @@ -15,7 +15,7 @@ struct List ~List() { - if (next == NULL) + if (next == nullptr) return; delete next; } @@ -25,31 +25,31 @@ template List *append(List *lst, T value) { List *node; - if (lst == NULL) + if (lst == nullptr) { node = new List; node->value = value; - node->next = NULL; + node->next = nullptr; return node; } - for (node = lst; node->next != NULL; node = node->next) + for (node = lst; node->next != nullptr; node = node->next) continue; node->next = new List; node->next->value = value; - node->next->next = NULL; + node->next->next = nullptr; return lst; } /** Reverse a list */ template -List *reverse(List *lst, List *prev = NULL) +List *reverse(List *lst, List *prev = nullptr) { auto next = lst->next; lst->next = prev; - if (next == NULL) + if (next == nullptr) return lst; return reverse(next, lst); } @@ -65,7 +65,7 @@ std::ostream& operator<<(std::ostream& ostream, const List *lst) int main(void) { - auto lst = append(NULL, 1); + auto lst = append(nullptr, 1); for (int i = 2; i < 10; ++i) lst = append(lst, i); std::cout << lst << std::endl; -- cgit v1.2.3-13-gbd6f