| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef TOOLBOX_LIST_SLL_H
- #define TOOLBOX_LIST_SLL_H
- #include "toolbox/errcode.h"
- #include "toolbox/errno.h"
- #include "toolbox/vptr.h"
- #include <stddef.h>
- struct sll_item {
- void *item;
- const size_t size;
- struct sll_item *next;
- };
- struct sll {
- size_t size;
- struct sll_item *head;
- };
- __attribute__((__pure__))
- struct sll *
- sll_create(void);
- RET_TYPE
- sll_destroy(struct sll **self);
- RET_TYPE
- sll_insert(struct sll *restrict self
- , const void *restrict item, const size_t item_size
- , const size_t index);
- RET_TYPE
- sll_append(struct sll *restrict self
- , const void *restrict item, const size_t item_size);
- struct vptr
- sll_remove(struct sll *self, const size_t index);
- struct vptr
- sll_get(struct sll *self, const size_t index);
- RET_TYPE
- sll_for_each(struct sll *self, RET_TYPE (*for_each)(void *, size_t));
- #define sll_size(self) \
- (self->size)
- #define sll_pop(self) \
- sll_remove(self, ssl_size(self))
- #define sll_prepend(self, item, item_size) \
- sll_insert(self, item, item_size, 0)
- #endif
|