SmartSnippets DA1459x SDK
Functions
sdk_queue.h File Reference

Simple helper to manage queue. More...

#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Functions

void queue_init (queue_t *q)
 
void queue_push_front (queue_t *q, void *data)
 
void queue_push_back (queue_t *q, void *data)
 
void * queue_pop_front (queue_t *q)
 
void * queue_peek_front (const queue_t *q)
 
void * queue_peek_back (const queue_t *q)
 
size_t queue_length (const queue_t *q)
 
void queue_foreach (const queue_t *q, queue_foreach_func_t func, void *user_data)
 
void * queue_find (const queue_t *q, queue_match_func_t func, const void *match_data)
 
void * queue_remove (queue_t *q, queue_match_func_t func, const void *match_data)
 
void queue_remove_all (queue_t *q, queue_destroy_func_t func)
 
void queue_filter (queue_t *q, queue_match_func_t m_func, const void *match_data, queue_destroy_func_t d_func)
 

Detailed Description

Simple helper to manage queue.

Copyright (C) 2015-2018 Renesas Electronics Corporation and/or its affiliates. All rights reserved. Confidential Information.

This software ("Software") is supplied by Renesas Electronics Corporation and/or its affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable, revocable, non-sub-licensable right and license to use the Software, solely if used in or together with Renesas products. You may make copies of this Software, provided this copyright notice and disclaimer ("Notice") is included in all such copies. Renesas reserves the right to change or discontinue the Software at any time without notice.

THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS SOFTWARE.

Function Documentation

◆ queue_filter()

void queue_filter ( queue_t *  q,
queue_match_func_t  m_func,
const void *  match_data,
queue_destroy_func_t  d_func 
)

Remove all matching elements from queue

Every element which matches using m_func is removed from queue. d_func callback is called for each element and it should be freed there.

Parameters
[in]qqueue structure
[in]m_funccallback matching function
[in]match_dataany pointer passed to callback function
[in]d_funccallback function to free element

◆ queue_find()

void* queue_find ( const queue_t *  q,
queue_match_func_t  func,
const void *  match_data 
)

Find element in queue

First element which matches using func is returned. Element IS NOT removed from queue

Parameters
[in]qqueue structure
[in]funccallback matching function
[in]match_dataany pointer passed to callback function
Returns
queue element

◆ queue_foreach()

void queue_foreach ( const queue_t *  q,
queue_foreach_func_t  func,
void *  user_data 
)

Execute callback for each element of queue

Parameters
[in]qqueue structure
[in]funccallback function
[in]user_dataany pointer passed to callback function

◆ queue_init()

void queue_init ( queue_t *  q)

Initialize queue structure

Parameters
[in]qqueue structure

◆ queue_length()

size_t queue_length ( const queue_t *  q)

Get number of elements on queue

Parameters
[in]qqueue structure
Returns
number of elements in queue

◆ queue_peek_back()

void* queue_peek_back ( const queue_t *  q)

Get element from the back of queue

Element is not removed from queue

Parameters
[in]qqueue structure
Returns
queue element

◆ queue_peek_front()

void* queue_peek_front ( const queue_t *  q)

Get element from the front of queue

Element is not removed from queue

Parameters
[in]qqueue structure
Returns
queue element

◆ queue_pop_front()

void* queue_pop_front ( queue_t *  q)

Remove element from the front of queue

Parameters
[in]qqueue structure
Returns
queue element

◆ queue_push_back()

void queue_push_back ( queue_t *  q,
void *  data 
)

Add element on the back of queue

Parameters
[in]qqueue structure
[in]dataqueue element

◆ queue_push_front()

void queue_push_front ( queue_t *  q,
void *  data 
)

Add element on the front of queue

Parameters
[in]qqueue structure
[in]dataqueue element

◆ queue_remove()

void* queue_remove ( queue_t *  q,
queue_match_func_t  func,
const void *  match_data 
)

Remove element from queue

First element which matches using func is returned. Element IS removed from queue

Parameters
[in]qqueue structure
[in]funccallback matching function
[in]match_dataany pointer passed to callback function
Returns
queue element

◆ queue_remove_all()

void queue_remove_all ( queue_t *  q,
queue_destroy_func_t  func 
)

Remove all elements from queue

Callback is called for each element and it should be freed there. Queue is empty after this call.

Parameters
[in]qqueue structure
[in]funccallback function to free element