2013-11-27 16:28:31 +01:00
|
|
|
/*
|
2013-06-18 17:21:38 +02:00
|
|
|
* Copyright (C) 2013 Freie Universität Berlin
|
2010-09-22 15:10:42 +02:00
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-06-18 17:21:38 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
2013-11-27 16:28:31 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup core_util
|
2010-09-22 15:10:42 +02:00
|
|
|
* @{
|
2013-11-27 16:28:31 +01:00
|
|
|
*
|
|
|
|
* @file clist.h
|
2014-03-31 13:56:26 +02:00
|
|
|
* @brief Circular linked list
|
2013-11-27 16:28:31 +01:00
|
|
|
*
|
2014-01-28 11:50:12 +01:00
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
2010-09-22 15:10:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CLIST_H
|
|
|
|
#define __CLIST_H
|
|
|
|
|
2014-03-31 13:56:26 +02:00
|
|
|
/**
|
|
|
|
* @brief Structure representing a node in the clist.
|
|
|
|
*/
|
2010-09-22 15:10:42 +02:00
|
|
|
typedef struct clist_node_t {
|
2014-03-31 13:56:26 +02:00
|
|
|
struct clist_node_t *next; /**< pointer to next node */
|
|
|
|
struct clist_node_t *prev; /**< pointer to the previous node */
|
|
|
|
unsigned int data; /**< holding data for this node */
|
2010-09-22 15:10:42 +02:00
|
|
|
} clist_node_t;
|
|
|
|
|
2014-03-31 13:56:26 +02:00
|
|
|
/**
|
|
|
|
* @brief Inserts *new_node* after *node* into list
|
|
|
|
*
|
|
|
|
* @param[in,out] node Node after which *new_node* gets inserted
|
|
|
|
* @param[in,out] new_node Node which gets inserted after *node*.
|
|
|
|
* Must not be NULL.
|
|
|
|
*/
|
2013-06-20 18:18:29 +02:00
|
|
|
void clist_add(clist_node_t **node, clist_node_t *new_node);
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2014-03-31 13:56:26 +02:00
|
|
|
/**
|
|
|
|
* @brief Removes *node* from list
|
|
|
|
*
|
|
|
|
* @param[in,out] list Pointer to the *list* to remove *node* from.
|
|
|
|
* @param[in] node Node to remove from *list*
|
|
|
|
* Must not be NULL.
|
|
|
|
*/
|
2013-06-20 18:18:29 +02:00
|
|
|
void clist_remove(clist_node_t **list, clist_node_t *node);
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2014-03-31 13:56:26 +02:00
|
|
|
/**
|
|
|
|
* @brief Advances the circle list.
|
2014-05-14 10:46:15 +02:00
|
|
|
*
|
2014-03-31 13:56:26 +02:00
|
|
|
* The result of this function is will be a list with
|
|
|
|
* nodes shifted by one. So second list entry will be
|
|
|
|
* first, first is last.
|
|
|
|
*
|
|
|
|
* @param[in,out] list The list to work upon.
|
|
|
|
*/
|
2013-06-20 18:18:29 +02:00
|
|
|
static inline void clist_advance(clist_node_t **list)
|
|
|
|
{
|
2010-09-22 15:10:42 +02:00
|
|
|
*list = (*list)->next;
|
|
|
|
}
|
|
|
|
|
2013-10-10 17:06:41 +02:00
|
|
|
#if ENABLE_DEBUG
|
2014-03-31 13:56:26 +02:00
|
|
|
/**
|
|
|
|
* @brief Prints list to stdout.
|
|
|
|
*
|
|
|
|
* @param[in] clist The list to get printed out.
|
|
|
|
*/
|
2013-06-20 18:18:29 +02:00
|
|
|
void clist_print(clist_node_t *clist);
|
2013-10-10 17:06:41 +02:00
|
|
|
#endif
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2014-03-31 13:56:26 +02:00
|
|
|
#endif /* __CLIST_H */
|
2013-11-27 16:28:31 +01:00
|
|
|
/** @} */
|