From 54affafd86e2b7f387345c08e8c7285c775d75e5 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Mon, 3 Mar 2025 23:53:14 +0100 Subject: Rename intrusive_list head & tail to front & back --- asl/containers/intrusive_list.hpp | 8 ++++---- asl/containers/intrusive_list_tests.cpp | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/asl/containers/intrusive_list.hpp b/asl/containers/intrusive_list.hpp index ce0c133..fc911ec 100644 --- a/asl/containers/intrusive_list.hpp +++ b/asl/containers/intrusive_list.hpp @@ -80,13 +80,13 @@ public: } } - constexpr auto head(this auto&& self) + constexpr auto front(this auto&& self) { using return_type = un_ref_t>*; return return_type{ self.m_head }; } - constexpr auto tail(this auto&& self) + constexpr auto back(this auto&& self) { using return_type = un_ref_t>*; return return_type{ self.m_head != nullptr ? self.m_head->m_prev : nullptr }; @@ -178,13 +178,13 @@ public: auto begin(this auto&& self) { using iterator_type = select_t>, const_iterator, iterator>; - return iterator_type{ self.head(), self.is_empty() }; + return iterator_type{ self.front(), self.is_empty() }; } auto end(this auto&& self) { using iterator_type = select_t>, const_iterator, iterator>; - return iterator_type{ self.head(), true }; + return iterator_type{ self.front(), true }; } }; diff --git a/asl/containers/intrusive_list_tests.cpp b/asl/containers/intrusive_list_tests.cpp index 5d2d97b..4e19237 100644 --- a/asl/containers/intrusive_list_tests.cpp +++ b/asl/containers/intrusive_list_tests.cpp @@ -19,8 +19,8 @@ ASL_TEST(empty_list) { const asl::IntrusiveList list; ASL_TEST_EXPECT(list.is_empty()); - ASL_TEST_EXPECT(list.head() == nullptr); - ASL_TEST_EXPECT(list.tail() == nullptr); + ASL_TEST_EXPECT(list.front() == nullptr); + ASL_TEST_EXPECT(list.back() == nullptr); } ASL_TEST(push_front) @@ -32,8 +32,8 @@ ASL_TEST(push_front) list.push_front(&one); ASL_TEST_EXPECT(!list.is_empty()); - ASL_TEST_EXPECT(list.head() == &one); - ASL_TEST_EXPECT(list.tail() == &one); + ASL_TEST_EXPECT(list.front() == &one); + ASL_TEST_EXPECT(list.back() == &one); auto it = list.begin(); auto end = list.end(); @@ -44,8 +44,8 @@ ASL_TEST(push_front) ASL_TEST_ASSERT(it == end); list.push_front(&two); - ASL_TEST_EXPECT(list.head() == &two); - ASL_TEST_EXPECT(list.tail() == &one); + ASL_TEST_EXPECT(list.front() == &two); + ASL_TEST_EXPECT(list.back() == &one); it = list.begin(); end = list.end(); @@ -58,8 +58,8 @@ ASL_TEST(push_front) ASL_TEST_ASSERT(it == end); list.push_front(&three); - ASL_TEST_EXPECT(list.head() == &three); - ASL_TEST_EXPECT(list.tail() == &one); + ASL_TEST_EXPECT(list.front() == &three); + ASL_TEST_EXPECT(list.back() == &one); it = list.begin(); end = list.end(); @@ -84,8 +84,8 @@ ASL_TEST(push_back) list.push_back(&one); ASL_TEST_EXPECT(!list.is_empty()); - ASL_TEST_EXPECT(list.head() == &one); - ASL_TEST_EXPECT(list.tail() == &one); + ASL_TEST_EXPECT(list.front() == &one); + ASL_TEST_EXPECT(list.back() == &one); auto it = list.begin(); auto end = list.end(); @@ -96,8 +96,8 @@ ASL_TEST(push_back) ASL_TEST_ASSERT(it == end); list.push_back(&two); - ASL_TEST_EXPECT(list.head() == &one); - ASL_TEST_EXPECT(list.tail() == &two); + ASL_TEST_EXPECT(list.front() == &one); + ASL_TEST_EXPECT(list.back() == &two); it = list.begin(); end = list.end(); @@ -110,8 +110,8 @@ ASL_TEST(push_back) ASL_TEST_ASSERT(it == end); list.push_back(&three); - ASL_TEST_EXPECT(list.head() == &one); - ASL_TEST_EXPECT(list.tail() == &three); + ASL_TEST_EXPECT(list.front() == &one); + ASL_TEST_EXPECT(list.back() == &three); it = list.begin(); end = list.end(); -- cgit