Wirepas SDK
sl_list.h
Go to the documentation of this file.
1/* Copyright 2017 Wirepas Ltd. All Rights Reserved.
2 *
3 * See file LICENSE.txt for full license details.
4 *
5 */
6
50#ifndef _SL_LIST_H
51#define _SL_LIST_H
52
53#include <stdint.h>
54
55typedef struct
56{
57 struct sl_list_t * next;
58 struct sl_list_t * last;
60 uint32_t size;
62
63typedef struct sl_list_t
64{
65 struct sl_list_t * next;
66} sl_list_t;
67
68void sl_list_init(sl_list_head_t * list_head);
69
70#define sl_list_empty(l) ((l)->next == NULL)
71//#define sl_list_set_empty(l) (l)->next = NULL
72
73/* returns an iterator to first element */
74//#define sl_list_begin(l) ((sl_list_t *)(l)->next)
75#define sl_list_begin(l) sl_list_next((sl_list_t *) l)
76
77/* return an iterator to one past last element */
78#define sl_list_end(l) ((sl_list_t *) NULL)
79
80#define sl_list_front(l) ((sl_list_t *)(l)->next)
81
82/* increases iterator by one */
83#define SL_LIST_ITER_NEXT(iter) { (iter) = (((sl_list_t *)(iter))->next); }
84
99
101 const sl_list_t * iter,
102 sl_list_t * element);
103
104void sl_list_push_back(sl_list_head_t * list_head, sl_list_t * element);
105
106void sl_list_push_front(sl_list_head_t * list_head, sl_list_t * element);
107
109
111
116
121
122/* Returns element at index. Does not perform boundary checking. */
123sl_list_t * sl_list_at(const sl_list_head_t * list_head, int idx);
124
125#define sl_list_size(l) ((l)->size)
126
130unsigned char sl_list_contains(const sl_list_head_t * list_head,
131 const sl_list_t * element);
132
134 int (*match)(const sl_list_t *, const void *),
135 const void * match_param);
136
141
142#endif
143
struct sl_list_t * last
Definition sl_list.h:58
struct sl_list_t * next
Definition sl_list.h:57
sl_list_t * sl_list_pop_front(sl_list_head_t *list_head)
sl_list_t * sl_list_at(const sl_list_head_t *list_head, int idx)
void sl_list_push_before(sl_list_head_t *list_head, const sl_list_t *iter, sl_list_t *element)
sl_list_t * sl_list_next(const sl_list_t *iter)
sl_list_t * sl_list_search(const sl_list_t *start, int(*match)(const sl_list_t *, const void *), const void *match_param)
unsigned char sl_list_contains(const sl_list_head_t *list_head, const sl_list_t *element)
void sl_list_swap(sl_list_head_t *list1, sl_list_head_t *list2)
void sl_list_push_front(sl_list_head_t *list_head, sl_list_t *element)
uint32_t size
Definition sl_list.h:60
sl_list_t * sl_list_pop_back(sl_list_head_t *list_head)
sl_list_t * sl_list_remove(sl_list_head_t *list_head, sl_list_t *element)
void sl_list_push_back(sl_list_head_t *list_head, sl_list_t *element)
void sl_list_init(sl_list_head_t *list_head)
sl_list_t * sl_list_pop(sl_list_head_t *list_head, sl_list_t *element)