mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 03:54:59 -05: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:
parent
f612e5ede7
commit
ab79b13079
@ -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.
|
* @brief Get the last item in the list.
|
||||||
*
|
*
|
||||||
|
@ -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_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_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_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);
|
alpm_list_t *alpm_list_last(const alpm_list_t *list);
|
||||||
void *alpm_list_getdata(const alpm_list_t *entry);
|
void *alpm_list_getdata(const alpm_list_t *entry);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user