#ifndef LINKED_LIST_H #define LINKED_LIST_H #include #include /** * @brief Data structure holding an element of a \a LinkedList */ typedef struct elt { int val; struct elt *next; } Element; /** * @brief Data structure holding a \a LinkedList */ typedef struct { Element *first; pthread_mutex_t mutex; } LinkedList; /** * @brief Creates a new \a LinkedList * @return The pointer on the created \a LinkedList */ LinkedList *newLL(); /** * @brief Displays on terminal the values contained in a \a LinkedList * @param[in] l the \a LinkedList to dump */ void dumpLL(LinkedList *l); /** * @brief Computes the number of elements in the list * @param[in] l the concerned \a LinkedList * @return Number of elements in the list (0 if empty) */ int sizeLL(LinkedList *l); /** * @brief Frees a \a LinkedList * @param[in] l the \a LinkedList to free */ void freeLL(LinkedList *l); /** * @brief Inserts a value in a \a LinkedList * @param[in] l the concerned \a LinkedList * @param[in] v the value to insert */ void addLL(LinkedList *l, int v); /** * @brief Removes a value from a \a LinkedList * @param[in] l the concerned \a LinkedList * @param[in] v the value to remove */ void removeLL(LinkedList *l, int v); #define MUTEX_LOCK(m) \ { \ int rc=pthread_mutex_lock(&(m)); \ assert(rc == 0); \ } /** * @brief Macro to unlock a mutex (and check that everything went right) */ #define MUTEX_UNLOCK(m) \ { \ int rc=pthread_mutex_unlock(&(m)); \ assert(rc == 0); \ } #endif /* LINKED_LIST_H */