include/boost/corosio/detail/intrusive.hpp
100.0% Lines (110/110)
100.0% List of functions (122/124)
20.9% Branches (125/598)
Functions (124)
Function
Calls
Lines
Branches
Blocks
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::node::node()
:33
14x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_descriptor>::node::node()
:33
61x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::node::node()
:33
125x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::node::node()
:33
55x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::node::node()
:33
162x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::node::node()
:33
2130x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::node::node()
:33
19927x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::node::node()
:33
166x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::node::node()
:33
424x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::node::node()
:33
222x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::node::node()
:33
63x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::node::node()
:33
193x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::node::node()
:33
635x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_descriptor>::node::node()
:33
60x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::node::node()
:33
121x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::node::node()
:33
53x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::node::node()
:33
156x
0.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::node::node()
:33
266x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::node::node()
:33
5028x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::node::node()
:33
159x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::node::node()
:33
26560x
100.0%
–
100.0%
<unknown function 43>
:43
–
–
–
–
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::intrusive_list()
:47
20x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_descriptor>::intrusive_list()
:47
106x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::intrusive_list()
:47
148x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::intrusive_list()
:47
94x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::intrusive_list()
:47
206x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::intrusive_list()
:47
1380x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::intrusive_list()
:47
1516x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::intrusive_list()
:47
222x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::intrusive_list()
:47
444x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::intrusive_list()
:47
334x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::intrusive_list()
:47
124x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::intrusive_list()
:47
664x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::intrusive_list()
:47
1158x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_descriptor>::intrusive_list()
:47
104x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::intrusive_list()
:47
144x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::intrusive_list()
:47
90x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::intrusive_list()
:47
198x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::intrusive_list()
:47
474x
0.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::intrusive_list()
:47
584x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::intrusive_list()
:47
214x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::intrusive_list()
:47
461564x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::intrusive_list(boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>&&)
:49
2x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::empty() const
:61
12x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::front() const
:67
6x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::push_back((anonymous namespace)::list_item*)
:72
19x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_descriptor>::push_back(boost::corosio::detail::kqueue_descriptor*)
:72
61x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::push_back(boost::corosio::detail::kqueue_local_datagram_socket*)
:72
125x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::push_back(boost::corosio::detail::kqueue_local_stream_acceptor*)
:72
55x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::push_back(boost::corosio::detail::kqueue_local_stream_socket*)
:72
162x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::push_back(boost::corosio::detail::kqueue_tcp_acceptor*)
:72
2130x
100.0%
64.3%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::push_back(boost::corosio::detail::kqueue_tcp_socket*)
:72
19927x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::push_back(boost::corosio::detail::kqueue_udp_socket*)
:72
166x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::push_back(boost::corosio::detail::posix_random_access_file::raf_op*)
:72
424x
100.0%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::push_back(boost::corosio::detail::posix_random_access_file*)
:72
222x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::push_back(boost::corosio::detail::posix_resolver*)
:72
63x
100.0%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::push_back(boost::corosio::detail::posix_signal*)
:72
199x
100.0%
66.7%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::push_back(boost::corosio::detail::posix_stream_file*)
:72
635x
88.9%
33.3%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_descriptor>::push_back(boost::corosio::detail::select_descriptor*)
:72
60x
100.0%
57.1%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::push_back(boost::corosio::detail::select_local_datagram_socket*)
:72
121x
100.0%
19.2%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::push_back(boost::corosio::detail::select_local_stream_acceptor*)
:72
53x
100.0%
61.5%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::push_back(boost::corosio::detail::select_local_stream_socket*)
:72
156x
0.0%
0.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::push_back(boost::corosio::detail::select_tcp_acceptor*)
:72
266x
100.0%
69.2%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::push_back(boost::corosio::detail::select_tcp_socket*)
:72
5028x
88.9%
14.3%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::push_back(boost::corosio::detail::select_udp_socket*)
:72
159x
100.0%
57.1%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::push_back(boost::corosio::detail::waiter_node*)
:72
10340x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::splice_back(boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>&)
:84
3x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::pop_front()
:103
14x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_descriptor>::pop_front()
:103
60x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::pop_front()
:103
74x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::pop_front()
:103
47x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::pop_front()
:103
103x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::pop_front()
:103
693x
92.3%
20.8%
76.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::pop_front()
:103
763x
100.0%
–
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::pop_front()
:103
111x
100.0%
–
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::pop_front()
:103
169x
92.3%
50.0%
76.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::pop_front()
:103
63x
92.3%
50.0%
76.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::pop_front()
:103
344x
92.3%
50.0%
76.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::pop_front()
:103
581x
30.8%
10.0%
76.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_descriptor>::pop_front()
:103
59x
100.0%
58.3%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::pop_front()
:103
72x
92.3%
5.5%
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::pop_front()
:103
45x
30.8%
9.1%
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::pop_front()
:103
99x
0.0%
0.0%
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::pop_front()
:103
239x
100.0%
63.6%
76.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::pop_front()
:103
296x
30.8%
4.2%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::pop_front()
:103
107x
30.8%
8.3%
23.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::waiter_node>::pop_front()
:103
241122x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::remove((anonymous namespace)::list_item*)
:121
4x
100.0%
83.3%
100.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_descriptor>::remove(boost::corosio::detail::kqueue_descriptor*)
:121
54x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_datagram_socket>::remove(boost::corosio::detail::kqueue_local_datagram_socket*)
:121
125x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_acceptor>::remove(boost::corosio::detail::kqueue_local_stream_acceptor*)
:121
55x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_local_stream_socket>::remove(boost::corosio::detail::kqueue_local_stream_socket*)
:121
162x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_acceptor>::remove(boost::corosio::detail::kqueue_tcp_acceptor*)
:121
2127x
92.3%
58.3%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_tcp_socket>::remove(boost::corosio::detail::kqueue_tcp_socket*)
:121
19922x
100.0%
–
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::kqueue_udp_socket>::remove(boost::corosio::detail::kqueue_udp_socket*)
:121
166x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::remove(boost::corosio::detail::posix_random_access_file::raf_op*)
:121
424x
100.0%
–
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file>::remove(boost::corosio::detail::posix_random_access_file*)
:121
220x
92.3%
50.0%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_resolver>::remove(boost::corosio::detail::posix_resolver*)
:121
62x
84.6%
50.0%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_signal>::remove(boost::corosio::detail::posix_signal*)
:121
187x
84.6%
50.0%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_stream_file>::remove(boost::corosio::detail::posix_stream_file*)
:121
633x
76.9%
33.3%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_descriptor>::remove(boost::corosio::detail::select_descriptor*)
:121
53x
84.6%
50.0%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_datagram_socket>::remove(boost::corosio::detail::select_local_datagram_socket*)
:121
121x
84.6%
14.7%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_acceptor>::remove(boost::corosio::detail::select_local_stream_acceptor*)
:121
53x
92.3%
58.3%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_local_stream_socket>::remove(boost::corosio::detail::select_local_stream_socket*)
:121
156x
0.0%
0.0%
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_acceptor>::remove(boost::corosio::detail::select_tcp_acceptor*)
:121
264x
92.3%
58.3%
73.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_tcp_socket>::remove(boost::corosio::detail::select_tcp_socket*)
:121
5024x
76.9%
16.7%
89.0%
boost::corosio::detail::intrusive_list<boost::corosio::detail::select_udp_socket>::remove(boost::corosio::detail::select_udp_socket*)
:121
159x
84.6%
50.0%
73.0%
void boost::corosio::detail::intrusive_list<(anonymous namespace)::list_item>::for_each<intrusive_test::testListForEach()::'lambda'((anonymous namespace)::list_item*)>(intrusive_test::testListForEach()::'lambda'((anonymous namespace)::list_item*))
:141
1x
100.0%
100.0%
100.0%
void boost::corosio::detail::intrusive_list<boost::corosio::detail::posix_random_access_file::raf_op>::for_each<boost::corosio::detail::posix_random_access_file::cancel()::'lambda'(boost::corosio::detail::posix_random_access_file::raf_op*)>(boost::corosio::detail::posix_random_access_file::cancel()::'lambda'(boost::corosio::detail::posix_random_access_file::raf_op*))
:141
642x
100.0%
75.0%
100.0%
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::node::node()
:170
6x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::node::node()
:170
1852x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::scheduler_op>::node::node()
:170
236521x
100.0%
–
100.0%
<unknown function 179>
:179
–
–
–
–
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::intrusive_queue()
:183
16x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::intrusive_queue()
:183
5940x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::intrusive_queue(boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>&&)
:185
2x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::empty() const
:197
10x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::empty() const
:197
1910x
100.0%
–
100.0%
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::push((anonymous namespace)::queue_item*)
:202
9x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::push(boost::corosio::detail::pool_work_item*)
:202
1106x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::splice(boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>&)
:212
3x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<(anonymous namespace)::queue_item>::pop()
:225
10x
100.0%
100.0%
100.0%
boost::corosio::detail::intrusive_queue<boost::corosio::detail::pool_work_item>::pop()
:225
4734x
100.0%
100.0%
100.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2025 Vinnie Falco ([email protected]) | |||
| 3 | // | |||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||
| 6 | // | |||
| 7 | // Official repository: https://github.com/cppalliance/corosio | |||
| 8 | // | |||
| 9 | ||||
| 10 | #ifndef BOOST_COROSIO_DETAIL_INTRUSIVE_HPP | |||
| 11 | #define BOOST_COROSIO_DETAIL_INTRUSIVE_HPP | |||
| 12 | ||||
| 13 | namespace boost::corosio::detail { | |||
| 14 | ||||
| 15 | /** An intrusive doubly linked list. | |||
| 16 | ||||
| 17 | This container provides O(1) push and pop operations for | |||
| 18 | elements that derive from @ref node. Elements are not | |||
| 19 | copied or moved; they are linked directly into the list. | |||
| 20 | ||||
| 21 | @tparam T The element type. Must derive from `intrusive_list<T>::node`. | |||
| 22 | */ | |||
| 23 | template<class T> | |||
| 24 | class intrusive_list | |||
| 25 | { | |||
| 26 | public: | |||
| 27 | /** Base class for list elements. | |||
| 28 | ||||
| 29 | Derive from this class to make a type usable with | |||
| 30 | @ref intrusive_list. The `next_` and `prev_` pointers | |||
| 31 | are private and accessible only to the list. | |||
| 32 | */ | |||
| 33 | 56580x | class node | ||
| 34 | { | |||
| 35 | friend class intrusive_list; | |||
| 36 | ||||
| 37 | private: | |||
| 38 | 56580x | T* next_ = nullptr; | ||
| 39 | 56580x | T* prev_ = nullptr; | ||
| 40 | }; | |||
| 41 | ||||
| 42 | private: | |||
| 43 | 234894x | T* head_ = nullptr; | ||
| 44 | 234894x | T* tail_ = nullptr; | ||
| 45 | ||||
| 46 | public: | |||
| 47 | 704682x | intrusive_list() = default; | ||
| 48 | ||||
| 49 | 2x | intrusive_list(intrusive_list&& other) noexcept | ||
| 50 | 1x | : head_(other.head_) | ||
| 51 | 1x | , tail_(other.tail_) | ||
| 52 | 1x | { | ||
| 53 | 1x | other.head_ = nullptr; | ||
| 54 | 1x | other.tail_ = nullptr; | ||
| 55 | 2x | } | ||
| 56 | ||||
| 57 | intrusive_list(intrusive_list const&) = delete; | |||
| 58 | intrusive_list& operator=(intrusive_list const&) = delete; | |||
| 59 | intrusive_list& operator=(intrusive_list&&) = delete; | |||
| 60 | ||||
| 61 | 12x | bool empty() const noexcept | ||
| 62 | { | |||
| 63 | 12x | return head_ == nullptr; | ||
| 64 | } | |||
| 65 | ||||
| 66 | /// Peek at the head element without removing it. | |||
| 67 | 6x | T* front() const noexcept | ||
| 68 | { | |||
| 69 | 6x | return head_; | ||
| 70 | } | |||
| 71 | ||||
| 72 | 40371x | void push_back(T* w) noexcept | ||
| 73 | { | |||
| 74 |
5/34✗ Branch 0 not taken.
✓ Branch 1 taken 20801 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2798 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5335 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 927 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 151 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
40371x | auto* n = static_cast<node*>(w); | |
| 75 | 40371x | n->next_ = nullptr; | ||
| 76 | 40371x | n->prev_ = tail_; | ||
| 77 |
12/36✓ Branch 0 taken 2961 times.
✓ Branch 1 taken 7909 times.
✓ Branch 2 taken 18177 times.
✓ Branch 3 taken 2537 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 2292 times.
✓ Branch 6 taken 4895 times.
✓ Branch 7 taken 440 times.
✓ Branch 8 taken 78 times.
✓ Branch 9 taken 849 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 48 times.
✓ Branch 27 taken 103 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
|
40371x | if (tail_) | |
| 78 |
7/38✗ Branch 0 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✓ Branch 1 taken 17935 times.
✗ Branch 2 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 242 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4895 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 48 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
26241x | static_cast<node*>(tail_)->next_ = w; | |
| 79 | else | |||
| 80 | 14130x | head_ = w; | ||
| 81 | 40371x | tail_ = w; | ||
| 82 | 40371x | } | ||
| 83 | ||||
| 84 | 3x | void splice_back(intrusive_list& other) noexcept | ||
| 85 | { | |||
| 86 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
|
3x | if (other.empty()) | |
| 87 | 1x | return; | ||
| 88 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2x | if (tail_) | |
| 89 | { | |||
| 90 | 1x | static_cast<node*>(tail_)->next_ = other.head_; | ||
| 91 | 1x | static_cast<node*>(other.head_)->prev_ = tail_; | ||
| 92 | 1x | tail_ = other.tail_; | ||
| 93 | 1x | } | ||
| 94 | else | |||
| 95 | { | |||
| 96 | 1x | head_ = other.head_; | ||
| 97 | 1x | tail_ = other.tail_; | ||
| 98 | } | |||
| 99 | 2x | other.head_ = nullptr; | ||
| 100 | 2x | other.tail_ = nullptr; | ||
| 101 | 3x | } | ||
| 102 | ||||
| 103 | 245061x | T* pop_front() noexcept | ||
| 104 | { | |||
| 105 |
11/34✓ Branch 0 taken 10368 times.
✓ Branch 1 taken 231371 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 997 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 866 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 834 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 102 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
245061x | if (!head_) | |
| 106 | 234663x | return nullptr; | ||
| 107 | 10398x | T* w = head_; | ||
| 108 |
4/32✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
10398x | head_ = static_cast<node*>(head_)->next_; | |
| 109 |
9/34✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 7489 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
10398x | if (head_) | |
| 110 |
3/34✗ Branch 0 not taken.
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
2891x | static_cast<node*>(head_)->prev_ = nullptr; | |
| 111 | else | |||
| 112 | 7507x | tail_ = nullptr; | ||
| 113 | // Defensive: clear stale linkage so remove() on a | |||
| 114 | // popped node cannot corrupt the list. | |||
| 115 |
4/32✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
10398x | auto* n = static_cast<node*>(w); | |
| 116 | 10398x | n->next_ = nullptr; | ||
| 117 | 10398x | n->prev_ = nullptr; | ||
| 118 | 10398x | return w; | ||
| 119 | 245061x | } | ||
| 120 | ||||
| 121 | 29971x | void remove(T* w) noexcept | ||
| 122 | { | |||
| 123 |
5/34✗ Branch 0 not taken.
✓ Branch 1 taken 20978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2584 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 923 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 151 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
29971x | auto* n = static_cast<node*>(w); | |
| 124 | // Already detached — nothing to do. | |||
| 125 |
24/136✓ Branch 0 taken 7482 times.
✓ Branch 1 taken 13500 times.
✓ Branch 2 taken 2785 times.
✓ Branch 3 taken 4697 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 2784 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 2584 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2452 times.
✓ Branch 11 taken 132 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2452 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2097 times.
✓ Branch 17 taken 3234 times.
✓ Branch 18 taken 437 times.
✓ Branch 19 taken 1660 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 437 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 923 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 845 times.
✓ Branch 27 taken 78 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 845 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✓ Branch 96 taken 151 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 103 times.
✓ Branch 99 taken 48 times.
✗ Branch 100 not taken.
✓ Branch 101 taken 103 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
|
29971x | if (!n->next_ && !n->prev_ && head_ != w && tail_ != w) | |
| 126 | 1x | return; | ||
| 127 |
10/34✓ Branch 0 taken 5092 times.
✓ Branch 1 taken 15889 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 2452 times.
✓ Branch 4 taken 1722 times.
✓ Branch 5 taken 3609 times.
✓ Branch 6 taken 78 times.
✓ Branch 7 taken 845 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 48 times.
✓ Branch 25 taken 103 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
29970x | if (n->prev_) | |
| 128 |
5/34✗ Branch 0 not taken.
✓ Branch 1 taken 5091 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1722 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 48 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
7072x | static_cast<node*>(n->prev_)->next_ = n->next_; | |
| 129 | else | |||
| 130 | 22898x | head_ = n->next_; | ||
| 131 |
7/34✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 7481 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2584 times.
✓ Branch 4 taken 3234 times.
✓ Branch 5 taken 2097 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 923 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 151 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
29970x | if (n->next_) | |
| 132 |
2/34✗ Branch 0 not taken.
✓ Branch 1 taken 13498 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3234 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
|
16734x | static_cast<node*>(n->next_)->prev_ = n->prev_; | |
| 133 | else | |||
| 134 | 13236x | tail_ = n->prev_; | ||
| 135 | 29970x | n->next_ = nullptr; | ||
| 136 | 29970x | n->prev_ = nullptr; | ||
| 137 | 29971x | } | ||
| 138 | ||||
| 139 | /// Invoke @p f for each element in the list. | |||
| 140 | template<class F> | |||
| 141 | 643x | void for_each(F f) | ||
| 142 | { | |||
| 143 |
3/4✓ Branch 0 taken 11 times.
✓ Branch 1 taken 643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
654x | for (T* p = head_; p; p = static_cast<node*>(p)->next_) | |
| 144 | 11x | f(p); | ||
| 145 | 643x | } | ||
| 146 | }; | |||
| 147 | ||||
| 148 | /** An intrusive singly linked FIFO queue. | |||
| 149 | ||||
| 150 | This container provides O(1) push and pop operations for | |||
| 151 | elements that derive from @ref node. Elements are not | |||
| 152 | copied or moved; they are linked directly into the queue. | |||
| 153 | ||||
| 154 | Unlike @ref intrusive_list, this uses only a single `next_` | |||
| 155 | pointer per node, saving memory at the cost of not supporting | |||
| 156 | O(1) removal of arbitrary elements. | |||
| 157 | ||||
| 158 | @tparam T The element type. Must derive from `intrusive_queue<T>::node`. | |||
| 159 | */ | |||
| 160 | template<class T> | |||
| 161 | class intrusive_queue | |||
| 162 | { | |||
| 163 | public: | |||
| 164 | /** Base class for queue elements. | |||
| 165 | ||||
| 166 | Derive from this class to make a type usable with | |||
| 167 | @ref intrusive_queue. The `next_` pointer is private | |||
| 168 | and accessible only to the queue. | |||
| 169 | */ | |||
| 170 | 238379x | class node | ||
| 171 | { | |||
| 172 | friend class intrusive_queue; | |||
| 173 | ||||
| 174 | private: | |||
| 175 | 238379x | T* next_ = nullptr; | ||
| 176 | }; | |||
| 177 | ||||
| 178 | private: | |||
| 179 | 2978x | T* head_ = nullptr; | ||
| 180 | 2978x | T* tail_ = nullptr; | ||
| 181 | ||||
| 182 | public: | |||
| 183 | 8934x | intrusive_queue() = default; | ||
| 184 | ||||
| 185 | 2x | intrusive_queue(intrusive_queue&& other) noexcept | ||
| 186 | 1x | : head_(other.head_) | ||
| 187 | 1x | , tail_(other.tail_) | ||
| 188 | 1x | { | ||
| 189 | 1x | other.head_ = nullptr; | ||
| 190 | 1x | other.tail_ = nullptr; | ||
| 191 | 2x | } | ||
| 192 | ||||
| 193 | intrusive_queue(intrusive_queue const&) = delete; | |||
| 194 | intrusive_queue& operator=(intrusive_queue const&) = delete; | |||
| 195 | intrusive_queue& operator=(intrusive_queue&&) = delete; | |||
| 196 | ||||
| 197 | 1920x | bool empty() const noexcept | ||
| 198 | { | |||
| 199 | 1920x | return head_ == nullptr; | ||
| 200 | } | |||
| 201 | ||||
| 202 | 1115x | void push(T* w) noexcept | ||
| 203 | { | |||
| 204 | 1115x | w->next_ = nullptr; | ||
| 205 |
2/2✓ Branch 0 taken 260 times.
✓ Branch 1 taken 855 times.
|
1115x | if (tail_) | |
| 206 | 260x | tail_->next_ = w; | ||
| 207 | else | |||
| 208 | 855x | head_ = w; | ||
| 209 | 1115x | tail_ = w; | ||
| 210 | 1115x | } | ||
| 211 | ||||
| 212 | 3x | void splice(intrusive_queue& other) noexcept | ||
| 213 | { | |||
| 214 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
|
3x | if (other.empty()) | |
| 215 | 1x | return; | ||
| 216 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2x | if (tail_) | |
| 217 | 1x | tail_->next_ = other.head_; | ||
| 218 | else | |||
| 219 | 1x | head_ = other.head_; | ||
| 220 | 2x | tail_ = other.tail_; | ||
| 221 | 2x | other.head_ = nullptr; | ||
| 222 | 2x | other.tail_ = nullptr; | ||
| 223 | 3x | } | ||
| 224 | ||||
| 225 | 4744x | T* pop() noexcept | ||
| 226 | { | |||
| 227 |
2/2✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 3629 times.
|
4744x | if (!head_) | |
| 228 | 3629x | return nullptr; | ||
| 229 | 1115x | T* w = head_; | ||
| 230 | 1115x | head_ = head_->next_; | ||
| 231 |
2/2✓ Branch 0 taken 261 times.
✓ Branch 1 taken 854 times.
|
1115x | if (!head_) | |
| 232 | 854x | tail_ = nullptr; | ||
| 233 | // Defensive: clear stale linkage on popped node. | |||
| 234 | 1115x | w->next_ = nullptr; | ||
| 235 | 1115x | return w; | ||
| 236 | 4744x | } | ||
| 237 | }; | |||
| 238 | ||||
| 239 | } // namespace boost::corosio::detail | |||
| 240 | ||||
| 241 | #endif | |||
| 242 |