eina: add eina_list_shuffle

Summary: add uniform shuffle to Eina_List

Reviewers: cedric

Differential Revision: https://phab.enlightenment.org/D27
This commit is contained in:
Jérémy Zurcher 2013-03-20 12:19:13 +01:00
parent d0f3357f77
commit b4cad3c370
4 changed files with 28 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2013-03-20 Jérémy Zurcher (jeyzu)
* Eina: Add eina_list_shuffle
2013-03-19 Mike Blumenkrantz 2013-03-19 Mike Blumenkrantz
* Fix magic failure in eina_value_array_count when array has not been allocated * Fix magic failure in eina_value_array_count when array has not been allocated

1
NEWS
View File

@ -6,6 +6,7 @@ Changes since 1.7.0:
-------------------- --------------------
Additions: Additions:
* Add eina_list_shuffle
* Add multiple font draws support to engines * Add multiple font draws support to engines
* eina : * eina :
- Add DOCTYPE children parsing in eina_simple_xml - Add DOCTYPE children parsing in eina_simple_xml

View File

@ -60,6 +60,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h>
#ifdef HAVE_EVIL #ifdef HAVE_EVIL
# include <Evil.h> # include <Evil.h>

View File

@ -886,8 +886,7 @@ EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUS
* nodes. * nodes.
* @return the new head of list. * @return the new head of list.
* *
* This function sorts @p list. @p size if the number of the first * This function sorts @p list. If @p limit is 0 or greater than the number of
* element to sort. If @p limit is 0 or greater than the number of
* elements in @p list, all the elements are sorted. @p func is used to * elements in @p list, all the elements are sorted. @p func is used to
* compare two elements of @p list. If @p func is @c NULL, this function returns * compare two elements of @p list. If @p func is @c NULL, this function returns
* @p list. * @p list.
@ -921,6 +920,27 @@ EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUS
EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int limit, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int limit, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
/**
* @brief Shuffle list.
*
* @param list The list handle to shuffle.
* @param func A function pointer that can return an int between 2 inclusives values
* @return the new head of list.
*
* This function shuffles @p list.
* @p func is used to generate random list indexes within the range of
* unshuffled list items. If @p func is @c NULL, rand is used.
*
* @note @b in-place: this will change the given list, so you should
* now point to the new list head that is returned by this function.
*
* @since 1.8
*
* @warning @p list must be a pointer to the first element of the list.
*/
EAPI Eina_List *eina_list_shuffle(Eina_List *list, Eina_Random_Cb func) EINA_WARN_UNUSED_RESULT;
/** /**
* @brief Merge two list. * @brief Merge two list.
* *