aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-03-20 12:19:13 +0100
committerChris Michael <cp.michael@samsung.com>2013-03-26 08:53:34 +0000
commit21fd4df8bf94a0f8b5068b8ae3436d4f86b261ad (patch)
treed2ebd595b97d5654cdd99aac0ca8cd5a339ad708
parentTES (diff)
downloadefl-21fd4df8bf94a0f8b5068b8ae3436d4f86b261ad.tar.gz
eina: add eina_list_shuffle
Summary: add uniform shuffle to Eina_List Reviewers: cedric Differential Revision: https://phab.enlightenment.org/D27
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rw-r--r--src/lib/eina/eina_list.c1
-rw-r--r--src/lib/eina/eina_list.h24
4 files changed, 28 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d3aaa09043..0c3403bae1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-20 Jérémy Zurcher (jeyzu)
+
+ * Eina: Add eina_list_shuffle
+
2013-03-19 Mike Blumenkrantz
* Fix magic failure in eina_value_array_count when array has not been allocated
diff --git a/NEWS b/NEWS
index db04703aca..706436f1e6 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Changes since 1.7.0:
--------------------
Additions:
+ * Add eina_list_shuffle
* Add multiple font draws support to engines
* eina :
- Add DOCTYPE children parsing in eina_simple_xml
diff --git a/src/lib/eina/eina_list.c b/src/lib/eina/eina_list.c
index 4e217dd9a6..5c8b1f8c41 100644
--- a/src/lib/eina/eina_list.c
+++ b/src/lib/eina/eina_list.c
@@ -60,6 +60,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#ifdef HAVE_EVIL
# include <Evil.h>
diff --git a/src/lib/eina/eina_list.h b/src/lib/eina/eina_list.h
index e70530bdb3..ebae94a66f 100644
--- a/src/lib/eina/eina_list.h
+++ b/src/lib/eina/eina_list.h
@@ -886,8 +886,7 @@ EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUS
* nodes.
* @return the new head of list.
*
- * This function sorts @p list. @p size if the number of the first
- * element to sort. If @p limit is 0 or greater than the number of
+ * This function sorts @p list. 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
* compare two elements of @p list. If @p func is @c NULL, this function returns
* @p list.
@@ -922,6 +921,27 @@ EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int limit, E
/**
+ * @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.
*
* @param left Head list to merge.