NiboRoboLib 3.6 - MThread Library
cdll.h
gehe zur Dokumentation dieser Datei
1 #ifndef CDLL_H
2 #define CDLL_H
3 
4 #include <stdbool.h>
5 
32 typedef struct _cdll_s
33 {
34  struct _cdll_s * prev;
35  struct _cdll_s * next;
36 } cdll_t;
37 
38 
39 
46 void cdll_reset(cdll_t *head);
47 
48 
52 static inline
53 bool cdll_is_empty(cdll_t *head);
54 
55 
60 void cdll_push_front(cdll_t * head, cdll_t * entry);
61 
62 
67 void cdll_push_back(cdll_t * head, cdll_t * entry);
68 
69 
74 void cdll_move_front(cdll_t * head, cdll_t * entry);
75 
76 
81 void cdll_move_back(cdll_t * head, cdll_t * entry);
82 
83 
88 cdll_t * cdll_pop_front(cdll_t * head);
89 
90 
95 cdll_t * cdll_pop_back(cdll_t * head);
96 
97 
102 static inline
103 cdll_t * cdll_peek_front(cdll_t * head);
104 
105 
110 static inline
111 cdll_t * cdll_peek_back(cdll_t * head);
112 
113 
117 void cdll_remove(cdll_t * entry);
118 
119 
123 bool cdll_contains(cdll_t * head, cdll_t * entry);
124 
125 
130 static inline
131 cdll_t * cdll_peek_front(cdll_t * head);
132 
133 
138 static inline
139 cdll_t * cdll_peek_back(cdll_t * head);
140 
141 
142 
143 
144 
145 
146 /* *** INLINE IMPLEMENTATIONS *** */
147 
148 
149 static inline bool cdll_is_empty(cdll_t *head) {
150  // assert (head!=0)
151  // (wenn head->next==head dann ist auch head->prev==head !!)
152  return head->next==head;
153 }
154 
155 
156 static inline cdll_t * cdll_peek_front(cdll_t * head) {
157  // assert (head!=0)
158  if (head->next==head) {
159  return (cdll_t *) 0;
160  }
161  return head->next;
162 }
163 
164 static inline cdll_t * cdll_peek_back(cdll_t * head) {
165  // assert (head!=0)
166  if (head->prev==head) {
167  return (cdll_t *) 0;
168  }
169  return head->prev;
170 }
171 
172 
173 
174 #endif
void cdll_move_back(cdll_t *head, cdll_t *entry)
Ein Element aus einer beliebigen CDLL entfernen und an das Ende der übergebenen CDLL setzen...
void cdll_push_front(cdll_t *head, cdll_t *entry)
Ein Element dem Anfang der CDLL hinzufügen.
void cdll_reset(cdll_t *head)
Listenkopf der CDLL initialisieren Die Liste ist nach dem Aufruf der Funktion leer und kann verwendet...
static cdll_t * cdll_peek_front(cdll_t *head)
Das erste Element der CDLL zurückliefern Liefert 0 zurück wenn die Liste leer ist.
Definition: cdll.h:156
void cdll_remove(cdll_t *entry)
Dieses Element aus seiner Liste entfernen.
cdll_t * cdll_pop_back(cdll_t *head)
Das letzte Element der CDLL entfernen und zurückliefern Liefert 0 zurück wenn die Liste leer ist...
static cdll_t * cdll_peek_back(cdll_t *head)
Das letzte Element der CDLL zurückliefern Liefert 0 zurück wenn die Liste leer ist.
Definition: cdll.h:164
static bool cdll_is_empty(cdll_t *head)
Prüft ob die CDLL-Liste leer ist (also nur aus dem Kopf besteht)
Definition: cdll.h:149
cdll_t * cdll_pop_front(cdll_t *head)
Das erste Element der CDLL entfernen und zurückliefern Liefert 0 zurück wenn die Liste leer ist...
bool cdll_contains(cdll_t *head, cdll_t *entry)
Prüfen ob dieses Element in der Liste enthalten ist.
void cdll_move_front(cdll_t *head, cdll_t *entry)
Ein Element aus einer beliebigen CDLL entfernen und an den Anfang der übergebenen CDLL setzen...
Definition: cdll.h:32
void cdll_push_back(cdll_t *head, cdll_t *entry)
Ein Element dem Ende der CDLL hinzufügen.