C Tool Box 0.1.0
Loading...
Searching...
No Matches
ctb_DListIterator.h File Reference
#include "ctb_DNode.h"
#include <stdbool.h>
#include "ctb_DList.h"

Go to the source code of this file.

Data Structures

struct  ctb_DListIterator
 Doubly linked list iterator data structure. More...
 

Typedefs

typedef struct ctb_DListIterator ctb_DListIterator_t
 Doubly linked list iterator type.
 
typedef bool(* ctb_DListIterator_FindPredicate_t) (ctb_DNode_t *const node)
 Typedef for predicate function used to find a node in the doubly linked list.
 
typedef void(* ctb_DListIterator_ForEachOperation_t) (ctb_DNode_t *const node)
 Typedef for operation function to be applied to each node in the doubly linked list.
 

Functions

ctb_DListIterator_tctb_DListIterator_init (ctb_DListIterator_t *const self, ctb_DList_t *const list)
 Initializes a doubly linked list iterator.
 
ctb_DListIterator_tctb_DListIterator_resetToFirst (ctb_DListIterator_t *const self)
 Resets the iterator to the first node.
 
ctb_DListIterator_tctb_DListIterator_resetToLast (ctb_DListIterator_t *const self)
 Resets the iterator to the last node.
 
bool ctb_DListIterator_hasNext (ctb_DListIterator_t *const self)
 Checks if there is a node after the current node.
 
bool ctb_DListIterator_hasPrevious (ctb_DListIterator_t *const self)
 Checks if there is a node before the current node.
 
ctb_DNode_tctb_DListIterator_next (ctb_DListIterator_t *const self)
 Returns the next node.
 
ctb_DNode_tctb_DListIterator_previous (ctb_DListIterator_t *const self)
 Returns the previous node.
 
void ctb_DListIterator_forEach (ctb_DListIterator_t *const self, ctb_DListIterator_ForEachOperation_t const operation)
 Applies an operation to each node in the doubly linked list.
 
ctb_DNode_tctb_DListIterator_find (ctb_DListIterator_t *const self, ctb_DListIterator_FindPredicate_t const predicate)
 Finds a node in the doubly linked list that satisfies a predicate.
 

Typedef Documentation

◆ ctb_DListIterator_FindPredicate_t

typedef bool(* ctb_DListIterator_FindPredicate_t) (ctb_DNode_t *const node)

Typedef for predicate function used to find a node in the doubly linked list.

Parameters
nodePointer to the node
Returns
True if the node satisfies the predicate, false otherwise

◆ ctb_DListIterator_ForEachOperation_t

typedef void(* ctb_DListIterator_ForEachOperation_t) (ctb_DNode_t *const node)

Typedef for operation function to be applied to each node in the doubly linked list.

Parameters
nodePointer to the node

Function Documentation

◆ ctb_DListIterator_find()

ctb_DNode_t * ctb_DListIterator_find ( ctb_DListIterator_t *const self,
ctb_DListIterator_FindPredicate_t const predicate )

Finds a node in the doubly linked list that satisfies a predicate.

Parameters
selfPointer to a doubly linked list iterator
predicatePredicate function
Returns
Pointer to the found node, or NULL if no node satisfies the predicate

◆ ctb_DListIterator_forEach()

void ctb_DListIterator_forEach ( ctb_DListIterator_t *const self,
ctb_DListIterator_ForEachOperation_t const operation )

Applies an operation to each node in the doubly linked list.

Parameters
selfPointer to a doubly linked list iterator
operationOperation to apply to each node

◆ ctb_DListIterator_hasNext()

bool ctb_DListIterator_hasNext ( ctb_DListIterator_t *const self)

Checks if there is a node after the current node.

Parameters
selfPointer to a doubly linked list iterator
Returns
True if there is a node after the current node, false otherwise

◆ ctb_DListIterator_hasPrevious()

bool ctb_DListIterator_hasPrevious ( ctb_DListIterator_t *const self)

Checks if there is a node before the current node.

Parameters
selfPointer to a doubly linked list iterator
Returns
True if there is a node before the current node, false otherwise

◆ ctb_DListIterator_init()

ctb_DListIterator_t * ctb_DListIterator_init ( ctb_DListIterator_t *const self,
ctb_DList_t *const list )

Initializes a doubly linked list iterator.

Parameters
selfPointer to a doubly linked list iterator
listPointer to the doubly linked list
Returns
Pointer to the initialized doubly linked list iterator

◆ ctb_DListIterator_next()

ctb_DNode_t * ctb_DListIterator_next ( ctb_DListIterator_t *const self)

Returns the next node.

Parameters
selfPointer to a doubly linked list iterator
Returns
Pointer to the next node, or NULL if there is no next node

◆ ctb_DListIterator_previous()

ctb_DNode_t * ctb_DListIterator_previous ( ctb_DListIterator_t *const self)

Returns the previous node.

Parameters
selfPointer to a doubly linked list iterator
Returns
Pointer to the previous node, or NULL if there is no previous node

◆ ctb_DListIterator_resetToFirst()

ctb_DListIterator_t * ctb_DListIterator_resetToFirst ( ctb_DListIterator_t *const self)

Resets the iterator to the first node.

Parameters
selfPointer to a doubly linked list iterator
Returns
Pointer to the doubly linked list iterator reset to the first node

◆ ctb_DListIterator_resetToLast()

ctb_DListIterator_t * ctb_DListIterator_resetToLast ( ctb_DListIterator_t *const self)

Resets the iterator to the last node.

Parameters
selfPointer to a doubly linked list iterator
Returns
Pointer to the doubly linked list iterator reset to the last node