#include "ctb_DListIterator.h"
#include "ctb_DNode.h"
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
|
typedef struct ctb_DList | ctb_DList_t |
| Doubly linked list type.
|
|
|
ctb_DList_t * | ctb_DList_init (ctb_DList_t *const self) |
| Initializes a doubly linked list.
|
|
void | ctb_DList_addByIndex (ctb_DList_t *const self, ctb_DNode_t *const node, size_t const index) |
| Adds a node at the specified index.
|
|
void | ctb_DList_addFirst (ctb_DList_t *const self, ctb_DNode_t *const node) |
| Adds a node at the beginning.
|
|
void | ctb_DList_addLast (ctb_DList_t *const self, ctb_DNode_t *const node) |
| Adds a node at the end.
|
|
ctb_DNode_t * | ctb_DList_getByIndex (ctb_DList_t *const self, size_t index) |
| Returns the node at the specified index.
|
|
ctb_DNode_t * | ctb_DList_getFirst (ctb_DList_t *const self) |
| Returns the first node.
|
|
ctb_DNode_t * | ctb_DList_getLast (ctb_DList_t *const self) |
| Returns the last node.
|
|
ctb_DNode_t * | ctb_DList_removeByIndex (ctb_DList_t *const self, size_t const index) |
| Removes the node at the specified index.
|
|
ctb_DNode_t * | ctb_DList_removeFirst (ctb_DList_t *const self) |
| Removes the first node.
|
|
ctb_DNode_t * | ctb_DList_removeLast (ctb_DList_t *const self) |
| Removes the last node.
|
|
ctb_DNode_t * | ctb_DList_remove (ctb_DList_t *const self, ctb_DNode_t *const node) |
| Removes a node.
|
|
size_t | ctb_DList_getIndexOf (ctb_DList_t *const self, ctb_DNode_t const *const node) |
| Returns the index of a node.
|
|
bool | ctb_DList_isEmpty (ctb_DList_t *const self) |
| Checks if the doubly linked list is empty.
|
|
size_t | ctb_DList_getSize (ctb_DList_t *const self) |
| Returns the size of the doubly linked list.
|
|
void | ctb_DList_clear (ctb_DList_t *const self) |
| Clears the doubly linked list.
|
|
void | ctb_DList_forEach (ctb_DList_t *const self, ctb_DListIterator_ForEachOperation_t const operation) |
| Applies an operation to each node of the doubly linked list.
|
|
ctb_DNode_t * | ctb_DList_find (ctb_DList_t *const self, ctb_DListIterator_FindPredicate_t const predicate) |
| Finds a node in the doubly linked list that matches a predicate.
|
|
◆ ctb_DList_addByIndex()
Adds a node at the specified index.
- Parameters
-
self | Pointer to a doubly linked list |
node | Pointer to the node to add |
index | Index where to add the node |
◆ ctb_DList_addFirst()
Adds a node at the beginning.
- Parameters
-
self | Pointer to a doubly linked list |
node | Pointer to the node to add |
◆ ctb_DList_addLast()
Adds a node at the end.
- Parameters
-
self | Pointer to a doubly linked list |
node | Pointer to the node to add |
◆ ctb_DList_clear()
Clears the doubly linked list.
- Parameters
-
self | Pointer to a doubly linked list |
◆ ctb_DList_find()
Finds a node in the doubly linked list that matches a predicate.
- Parameters
-
self | Pointer to a doubly linked list |
predicate | Predicate to match a node |
- Returns
- Pointer to the first node that matches the predicate, or NULL if no node matches
◆ ctb_DList_forEach()
Applies an operation to each node of the doubly linked list.
- Parameters
-
self | Pointer to a doubly linked list |
operation | Operation to apply to each node |
◆ ctb_DList_getByIndex()
Returns the node at the specified index.
- Parameters
-
self | Pointer to a doubly linked list |
index | Index of the node to return |
- Returns
- Pointer to the node at the specified index
◆ ctb_DList_getFirst()
Returns the first node.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- Pointer to the first node
◆ ctb_DList_getIndexOf()
Returns the index of a node.
- Parameters
-
self | Pointer to a doubly linked list |
node | Pointer to the node |
- Returns
- Index of the node, or SIZE_MAX if the node is not found
◆ ctb_DList_getLast()
Returns the last node.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- Pointer to the last node
◆ ctb_DList_getSize()
Returns the size of the doubly linked list.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- Size of the doubly linked list
◆ ctb_DList_init()
Initializes a doubly linked list.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- Pointer to the initialized doubly linked list
◆ ctb_DList_isEmpty()
Checks if the doubly linked list is empty.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- True if the doubly linked list is empty, false otherwise
◆ ctb_DList_remove()
Removes a node.
- Parameters
-
self | Pointer to a doubly linked list |
node | Pointer to the node to remove |
- Returns
- Pointer to the removed node
◆ ctb_DList_removeByIndex()
Removes the node at the specified index.
- Parameters
-
self | Pointer to a doubly linked list |
index | Index of the node to remove |
- Returns
- Pointer to the removed node
◆ ctb_DList_removeFirst()
Removes the first node.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- Pointer to the removed node
◆ ctb_DList_removeLast()
Removes the last node.
- Parameters
-
self | Pointer to a doubly linked list |
- Returns
- Pointer to the removed node