Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef LINKEDL_H
- #define LINKEDL_H
- #include <stdlib.h>
- /*Singly linked list*/
- #define SINGLE_LINKED_LIST(x,y) typedef struct t_##y { \
- struct t_##y * next; \
- x content; \
- } y; \
- y * y##_findLast(y * intro) { \
- y * anchor; \
- for(anchor=0;anchor.next;anchor = anchor.next); \
- return anchor; \
- }
- /*Double linked list*/
- #define DOUBLE_LINKED_LIST(x,y) typedef struct t_##y { \
- struct t_##y *prev; \
- struct t_##y *next; \
- x content; \
- } y; \
- y * y##_findLast(y * intro) { \
- y * anchor; \
- for(anchor=0;anchor->next;anchor = anchor->next); \
- return anchor; \
- } \
- y * y##_findFirst(y * intro) { \
- y * anchor; \
- for(anchor=0;anchor->prev;anchor = anchor->prev); \
- return anchor; \
- }
- /*Non-null terminated container */
- #define CONTAINER(x,y) typedef struct t_##y { \
- x * content; \
- size_t num; \
- } y; \
- y * y##_initialize(size_t size) { \
- y * temp; \
- temp = (y*)malloc(sizeof(y)); \
- temp->num = size; \
- temp->content = (x*)malloc(sizeof(x) * size); \
- return temp; \
- }
- #endif /* LINKEDL_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement