#ifndef CA_UWATERLOO_DWHARDER_C_LINKED_LIST_GENERIC_T #define CA_UWATERLOO_DWHARDER_C_LINKED_LIST_GENERIC_T #include // Needed for type 'bool' #include // Needed for type 'size_t' #define LINKED_LIST_PRIMITIVE_DECLARE( T ) \ struct node_##T; \ struct linked_list_##T; \ \ typedef struct node_##T node_##T##_t; \ typedef struct linked_list_##T linked_list_##T##_t; \ \ struct node_##T { \ T value; \ node_##T##_t *p_next; \ }; \ \ struct linked_list_##T { \ node_##T##_t *p_head; \ node_##T##_t *p_tail; \ size_t size; \ }; \ \ void linked_list_init_##T( linked_list_##T##_t *p_list ); \ \ T front_##T( linked_list_##T##_t *p_list, bool *p_valid ); \ T back_##T( linked_list_##T##_t *p_list, bool *p_valid ); \ \ void push_front_##T( linked_list_##T##_t *p_list, T new_value ); \ void push_back_##T( linked_list_##T##_t *p_list, T new_value ); \ void pop_front_##T( linked_list_##T##_t *p_list ); \ \ node_##T##_t *find_##T( linked_list_##T##_t *p_list, T sought_value ); LINKED_LIST_PRIMITIVE_DECLARE( int ) LINKED_LIST_PRIMITIVE_DECLARE( double ) #endif