aboutsummaryrefslogtreecommitdiff
path: root/list.cpp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2021-11-22 05:52:49 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2021-11-22 05:52:49 +0000
commit1537bb705bc7952fe8a0c94cacc9c434cba8d23d (patch)
treed6962262c1118003c00ff2179dfe3fb567cdcf17 /list.cpp
parent36d5eb111a4ffcebcdf9d95e56c09df056914f64 (diff)
downloadalgorithms-1537bb705bc7952fe8a0c94cacc9c434cba8d23d.tar.gz
algorithms-1537bb705bc7952fe8a0c94cacc9c434cba8d23d.tar.bz2
algorithms-1537bb705bc7952fe8a0c94cacc9c434cba8d23d.zip
(list)~NULL -> nullptr
C++ styling.
Diffstat (limited to 'list.cpp')
-rw-r--r--list.cpp16
1 files 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 <typename T>
List<T> *append(List<T> *lst, T value)
{
List<T> *node;
- if (lst == NULL)
+ if (lst == nullptr)
{
node = new List<T>;
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<T>;
node->next->value = value;
- node->next->next = NULL;
+ node->next->next = nullptr;
return lst;
}
/** Reverse a list
*/
template <typename T>
-List<T> *reverse(List<T> *lst, List<T> *prev = NULL)
+List<T> *reverse(List<T> *lst, List<T> *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<T> *lst)
int main(void)
{
- auto lst = append<int>(NULL, 1);
+ auto lst = append<int>(nullptr, 1);
for (int i = 2; i < 10; ++i)
lst = append(lst, i);
std::cout << lst << std::endl;