1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

Add alpm_list_previous method

Helper function to get the previous item in a list

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Allan McRae 2011-07-03 10:10:36 +10:00 committed by Dan McGee
parent f612e5ede7
commit ab79b13079
2 changed files with 19 additions and 0 deletions

View File

@ -555,6 +555,24 @@ inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node)
}
}
/**
* @brief Get the previous element of a list.
*
* @param list the list head
* @param node the list node
*
* @return the previous element, or NULL when no previous element exist
*/
inline alpm_list_t SYMEXPORT *alpm_list_previous(const alpm_list_t *list,
const alpm_list_t *node)
{
if(node && node != list) {
return node->prev;
} else {
return NULL;
}
}
/**
* @brief Get the last item in the list.
*

View File

@ -70,6 +70,7 @@ alpm_list_t *alpm_list_reverse(alpm_list_t *list);
alpm_list_t *alpm_list_first(const alpm_list_t *list);
alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n);
alpm_list_t *alpm_list_next(const alpm_list_t *list);
alpm_list_t *alpm_list_previous(const alpm_list_t *list, const alpm_list_t *node);
alpm_list_t *alpm_list_last(const alpm_list_t *list);
void *alpm_list_getdata(const alpm_list_t *entry);