Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
list_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/list_impl.h
10//! @brief Intrusive doubly-linked list implementation.
11
12#ifndef ROC_CORE_LIST_IMPL_H_
13#define ROC_CORE_LIST_IMPL_H_
14
15#include "roc_core/list_node.h"
17#include "roc_core/stddefs.h"
18
19namespace roc {
20namespace core {
21
22//! Intrusive doubly-linked list implementation class.
23//! Handles List infrastructure independent of templated type for List.
24//! Ownership handling is left to the main List class.
25class ListImpl : public NonCopyable<> {
26public:
27 ListImpl();
28 ~ListImpl();
29
30 //! Get number of nodes in list.
31 size_t size() const;
32
33 //! Check if node belongs to list.
34 bool contains(const ListData* node) const;
35
36 //! Get list head (non-node node).
38
39 //! Get first list node.
40 ListData* front() const;
41
42 //! Get last list node.
43 ListData* back() const;
44
45 //! Get list node next to given one.
46 ListData* nextof(ListData* node) const;
47
48 //! Get list node previous to given one.
49 ListData* prevof(ListData* node) const;
50
51 //! Remove first node and return.
53
54 //! Remove last node and return.
56
57 //! Insert node into list.
59
60 //! Remove node from list.
61 void remove(ListData* node);
62
63private:
64 static void check_is_member_(const ListData* node, const ListImpl* list);
65
66 ListData head_;
67 size_t size_;
68};
69
70} // namespace core
71} // namespace roc
72
73#endif // ROC_CORE_LIST_IMPL_H_
Intrusive doubly-linked list implementation class. Handles List infrastructure independent of templat...
Definition list_impl.h:25
ListData * nextof(ListData *node) const
Get list node next to given one.
ListData * pop_back()
Remove last node and return.
ListData * head()
Get list head (non-node node).
ListData * back() const
Get last list node.
void remove(ListData *node)
Remove node from list.
ListData * front() const
Get first list node.
void insert(ListData *node, ListData *before)
Insert node into list.
bool contains(const ListData *node) const
Check if node belongs to list.
ListData * prevof(ListData *node) const
Get list node previous to given one.
ListData * pop_front()
Remove first node and return.
size_t size() const
Get number of nodes in list.
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Linked list node.
Root namespace.
Non-copyable object.
Commonly used types and functions.
List node internal data.
Definition list_node.h:24