Skip to main content

doubly-list.h File

C++ header file with the declarations for the µOS++ doubly linked list iterator and list class templates. More...

Included Headers

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespaceutils

The µOS++ utilities definitions. More...

Classes Index

classdoubly_list<T, L>

A class template for a doubly linked list of nodes. More...

classdoubly_list_iterator<T, N, U>

A class template for a doubly linked list iterator. More...

Description

C++ header file with the declarations for the µOS++ doubly linked list iterator and list class templates.

The doubly-list.h header file contains the C++ declarations of the doubly_list_iterator and doubly_list class templates.

The class implementations are in doubly-list-inlines.h.

File Listing

The file content with the documentation metadata removed is:

1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2016-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can be
9 * obtained from https://opensource.org/licenses/mit.
10 */
11
12// ----------------------------------------------------------------------------
24
25#ifndef MICRO_OS_PLUS_UTILS_LISTS_DOUBLY_LIST_H_
26#define MICRO_OS_PLUS_UTILS_LISTS_DOUBLY_LIST_H_
27
28// ----------------------------------------------------------------------------
29
30#include "doubly-list-links.h"
31
32// ----------------------------------------------------------------------------
33
34#if defined(__cplusplus)
35
36// ----------------------------------------------------------------------------
37
38#if defined(__GNUC__)
39#pragma GCC diagnostic push
40
41#pragma GCC diagnostic ignored "-Waggregate-return"
42#if defined(__clang__)
43#pragma clang diagnostic ignored "-Wc++98-compat"
44#endif // defined(__clang__)
45#endif // defined(__GNUC__)
46
48{
49 // ==========================================================================
50
68 template <class T, class N = T, class U = T>
70 {
71 public:
75 using value_type = U;
76
81
86
90 using iterator_pointer = N*;
91
95 using difference_type = ptrdiff_t;
96
100 using iterator_category = std::bidirectional_iterator_tag;
101
102 // ------------------------------------------------------------------------
103
108 constexpr doubly_list_iterator () noexcept;
109
115 constexpr explicit doubly_list_iterator (
116 iterator_pointer const node) noexcept;
117
124 constexpr explicit doubly_list_iterator (reference element) noexcept;
125
126 // DO NOT delete the copy constructors, since the default ones are
127 // used.
128
134 [[nodiscard]] constexpr pointer
135 operator->() const noexcept;
136
142 [[nodiscard]] constexpr reference
143 operator* () const noexcept;
144
150 constexpr doubly_list_iterator&
151 operator++ () noexcept;
152
158 constexpr doubly_list_iterator
159 operator++ (int) noexcept;
160
166 constexpr doubly_list_iterator&
167 operator-- () noexcept;
168
174 constexpr doubly_list_iterator
175 operator-- (int) noexcept;
176
188 [[nodiscard]] constexpr bool
189 operator== (const doubly_list_iterator& other) const noexcept;
190
198 [[nodiscard]] constexpr pointer
199 get_pointer (void) const noexcept;
200
208 [[nodiscard]] constexpr iterator_pointer
209 get_iterator_pointer (void) const noexcept;
210
211 protected:
216 };
217
218 // ==========================================================================
219
248 template <doubly_list_links_node T,
251 {
252 public:
257 using links_type = L;
258
262 using value_type = T;
263
268
273
278
282 using reverse_iterator = std::reverse_iterator<iterator>;
283
288
293 typename links_type::is_statically_allocated;
294
298 doubly_list () noexcept;
299
308 doubly_list (const doubly_list&) = delete;
309
319
329 operator= (const doubly_list&)
330 = delete;
331
340 operator= (doubly_list&&)
341 = delete;
342
346 constexpr ~doubly_list ();
347
348 public:
358 [[nodiscard]] bool
359 initialised (void) const noexcept;
360
369 bool
370 initialise_once (void) noexcept;
371
380 [[nodiscard]] constexpr bool
381 empty (void) const noexcept;
382
391 void
392 clear (void) noexcept;
393
401 [[nodiscard]] constexpr pointer
402 head (void) const noexcept;
403
411 [[nodiscard]] constexpr pointer
412 tail (void) const noexcept;
413
421 void
422 link_tail (reference node) noexcept;
423
431 void
432 link_head (reference node) noexcept;
433
434 // ------------------------------------------------------------------------
435
441 [[nodiscard]] iterator
442 begin () const noexcept;
443
449 [[nodiscard]] iterator
450 end () const noexcept;
451
457 [[nodiscard]] reverse_iterator
458 rbegin () const noexcept;
459
465 [[nodiscard]] reverse_iterator
466 rend () const noexcept;
467
468 // Required in derived class iterator end(), where direct
469 // access to member fails.
483 [[nodiscard]] constexpr const links_type*
484 links_pointer (void) const noexcept;
485
486 // ------------------------------------------------------------------------
487
488 protected:
500 };
501
502 // --------------------------------------------------------------------------
503} // namespace micro_os_plus::utils
504
505#if defined(__GNUC__)
506#pragma GCC diagnostic pop
507#endif // defined(__GNUC__)
508
509// ----------------------------------------------------------------------------
510
511#endif // defined(__cplusplus)
512
513// ============================================================================
514// Templates & constexpr implementations.
515
517
518// ----------------------------------------------------------------------------
519
520#endif // MICRO_OS_PLUS_UTILS_LISTS_DOUBLY_LIST_H_
521
522// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.