Re: [E-devel] [EGIT] [core/efl] master 01/02: TES
On Wed, Mar 20, 2013 at 11:15 AM, Jérémy Zurcher - Enlightenment Git no-re...@enlightenment.org wrote: jeyzu pushed a commit to branch master. commit d0f3357f7778f415f4dae25e2fac4bcc5d1ea8d1 Author: Jérémy Zurcher jer...@asynk.ch Date: Wed Mar 20 11:45:57 2013 +0100 TES Conflicts: src/lib/eina/eina_list.c src/lib/eina/eina_types.h --- src/lib/eina/eina_list.c| 79 + src/lib/eina/eina_types.h | 15 src/tests/eina/eina_test_list.c | 57 + 3 files changed, 151 insertions(+) What is TES ? -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] [EGIT] [core/efl] master 01/02: TES
On 20/03/13 11:15, J챕r챕my Zurcher - Enlightenment Git wrote: jeyzu pushed a commit to branch master. commit d0f3357f7778f415f4dae25e2fac4bcc5d1ea8d1 Author: Jérémy Zurcher jer...@asynk.ch Date: Wed Mar 20 11:45:57 2013 +0100 TES Not the kind of commit message I would have expected for a commit like this. ;-) Conflicts: src/lib/eina/eina_list.c src/lib/eina/eina_types.h It seems to me you did a rebase which conflicted. You resolved this conflict and committed the result manually - with a temporary commit message. Am I on the right track? You should rather - after resolving the conflict - use git add on the relevant files to mark these resolved and then issue git rebase --continue to continue with the rebase. This should then continue as usual without adding an extra commit. Regards, Daniel --- src/lib/eina/eina_list.c| 79 + src/lib/eina/eina_types.h | 15 src/tests/eina/eina_test_list.c | 57 + 3 files changed, 151 insertions(+) diff --git a/src/lib/eina/eina_list.c b/src/lib/eina/eina_list.c index 01871b2..4e217dd 100644 --- a/src/lib/eina/eina_list.c +++ b/src/lib/eina/eina_list.c @@ -1095,6 +1095,85 @@ eina_list_sort(Eina_List *list, unsigned int limit, Eina_Compare_Cb func) } EAPI Eina_List * +eina_list_shuffle(Eina_List *list, Eina_Random_Cb func) +{ + unsigned int n, i, j; + Eina_List_Accounting *accounting; + Eina_List *shuffled_list, *shuffled_last, *li; + + if (!list) + return NULL; + + EINA_MAGIC_CHECK_LIST(list, NULL); + + accounting = list-accounting; + n = accounting-count; + shuffled_list = shuffled_last = NULL; + + if (n == 1) + return list; + + while (n 1) + { +if (func) + i = func(0, (n - 1)); +else + i = (int) ((float)n*rand()/(RAND_MAX+1.0)); + +if(i == 0) + { + li = list; + list = list-next; + } +else if (i == (n - 1) || i == n) + { + li = accounting-last; + accounting-last = li-prev; + } +else + { + if (i (n / 2)) + for (j = n - 1, +li = accounting-last; +j!=i; +li = li-prev, j--); + else + for (j = 0, +li = list; +j!=i; +li = li-next, j++); + + li-prev-next = li-next; + li-next-prev = li-prev; + } + +n--; + +if (shuffled_list == NULL) + { + li-prev = NULL; + shuffled_list = li; + shuffled_last = li; + } +else + { + shuffled_last-next = li; + li-prev = shuffled_last; + shuffled_last = li; + } + } + + list-next = NULL; + list-prev = shuffled_last; + shuffled_last-next = list; + + accounting-last = list; + shuffled_list-accounting = accounting; + + return shuffled_list; +} + +EAPI Eina_List * eina_list_merge(Eina_List *left, Eina_List *right) { unsigned int n_left, n_right; diff --git a/src/lib/eina/eina_types.h b/src/lib/eina/eina_types.h index d74d200..d37b20f 100644 --- a/src/lib/eina/eina_types.h +++ b/src/lib/eina/eina_types.h @@ -334,6 +334,21 @@ typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2); #define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function) /** + * @typedef Eina_Random_Cb + * Function used in shuffling functions. An integer betwen min and max + * inclusive must be returned. + * + * @since 1.8 + */ +typedef int (*Eina_Random_Cb)(const int min, const int max); + +/** + * @def EINA_RANDOM_CB + * Macro to cast to Eina_Random_Cb. + */ +#define EINA_RANDOM_CB(function) ((Eina_Random_Cb)function) + +/** * @typedef Eina_Each_Cb * A callback type used when iterating over a container. */ diff --git a/src/tests/eina/eina_test_list.c b/src/tests/eina/eina_test_list.c index 0f48688..fd11f89 100644 --- a/src/tests/eina/eina_test_list.c +++ b/src/tests/eina/eina_test_list.c @@ -375,6 +375,62 @@ START_TEST(eina_test_list_split) } END_TEST +static int uicmp(const void *d1, const void *d2) +{ + const unsigned int *a = d1; + const unsigned int *b = d2; + + if(*a == *b) return 0; + if(*a *b) return 1; + + return -1; +} + +#define SHUFFLE_SZ 100 +#define SHUFFLE_N 10 +START_TEST(eina_test_shuffle) +{ + double d; + unsigned int *p; + unsigned int i, j; + unsigned int n[SHUFFLE_SZ]; + unsigned int rand_count[SHUFFLE_SZ]; + Eina_List *list = NULL; + Eina_List *item = NULL; + + eina_init(); + + for(i = 0; i SHUFFLE_SZ; i++) +{ + n[i] = i; + rand_count[i] = 0; + list =
Re: [E-devel] [EGIT] [core/efl] master 01/02: TES
On 20/03/13 12:06, Daniel Willmann wrote: On 20/03/13 11:15, J챕r챕my Zurcher - Enlightenment Git wrote: jeyzu pushed a commit to branch master. commit d0f3357f7778f415f4dae25e2fac4bcc5d1ea8d1 Author: Jérémy Zurcher jer...@asynk.ch Date: Wed Mar 20 11:45:57 2013 +0100 TES Not the kind of commit message I would have expected for a commit like this. ;-) Also - now efl breaks: http://jenkins.enlightenment.org/job/efl/120/compiler=gcc,label=e5-jenkins-slave-x86_64-1/console 04:42:24 PASS: tests/eeze/eeze_suite 04:42:56 ../test-driver: line 95: 14920 Segmentation fault $@ $log_file 21 04:42:56 FAIL: tests/eina/eina_suite 04:44:00 PASS: tests/ecore/ecore_suite Daniel -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
Re: [E-devel] [EGIT] [core/efl] master 01/02: TES
Sorry for the mess you are very close, I was trying to use arc with a revision composed of a few commits … didn't end up right, lost my good commit msg too ;(( (I hate a php scipt which emits git push cmds in my back) my advise to the which will try this: - have only 1 commit per revision, rewrite it if needed using i.e. $ git reset --soft HEAD~1 $ git add ... $ git commit .. $ arc diff --update id when ready, from your revision branch $ arc land --update-with-rebase --revision id (--keep-branch) should work better than the smelly crap I'm so annoyed to have done On Wednesday 20 March 2013 12:06, Daniel Willmann wrote : On 20/03/13 11:15, J챕r챕my Zurcher - Enlightenment Git wrote: jeyzu pushed a commit to branch master. commit d0f3357f7778f415f4dae25e2fac4bcc5d1ea8d1 Author: Jérémy Zurcher jer...@asynk.ch Date: Wed Mar 20 11:45:57 2013 +0100 TES Not the kind of commit message I would have expected for a commit like this. ;-) Conflicts: src/lib/eina/eina_list.c src/lib/eina/eina_types.h It seems to me you did a rebase which conflicted. You resolved this conflict and committed the result manually - with a temporary commit message. Am I on the right track? You should rather - after resolving the conflict - use git add on the relevant files to mark these resolved and then issue git rebase --continue to continue with the rebase. This should then continue as usual without adding an extra commit. Regards, Daniel --- src/lib/eina/eina_list.c| 79 + src/lib/eina/eina_types.h | 15 src/tests/eina/eina_test_list.c | 57 + 3 files changed, 151 insertions(+) diff --git a/src/lib/eina/eina_list.c b/src/lib/eina/eina_list.c index 01871b2..4e217dd 100644 --- a/src/lib/eina/eina_list.c +++ b/src/lib/eina/eina_list.c @@ -1095,6 +1095,85 @@ eina_list_sort(Eina_List *list, unsigned int limit, Eina_Compare_Cb func) } EAPI Eina_List * +eina_list_shuffle(Eina_List *list, Eina_Random_Cb func) +{ + unsigned int n, i, j; + Eina_List_Accounting *accounting; + Eina_List *shuffled_list, *shuffled_last, *li; + + if (!list) + return NULL; + + EINA_MAGIC_CHECK_LIST(list, NULL); + + accounting = list-accounting; + n = accounting-count; + shuffled_list = shuffled_last = NULL; + + if (n == 1) + return list; + + while (n 1) + { +if (func) + i = func(0, (n - 1)); +else + i = (int) ((float)n*rand()/(RAND_MAX+1.0)); + +if(i == 0) + { + li = list; + list = list-next; + } +else if (i == (n - 1) || i == n) + { + li = accounting-last; + accounting-last = li-prev; + } +else + { + if (i (n / 2)) + for (j = n - 1, +li = accounting-last; +j!=i; +li = li-prev, j--); + else + for (j = 0, +li = list; +j!=i; +li = li-next, j++); + + li-prev-next = li-next; + li-next-prev = li-prev; + } + +n--; + +if (shuffled_list == NULL) + { + li-prev = NULL; + shuffled_list = li; + shuffled_last = li; + } +else + { + shuffled_last-next = li; + li-prev = shuffled_last; + shuffled_last = li; + } + } + + list-next = NULL; + list-prev = shuffled_last; + shuffled_last-next = list; + + accounting-last = list; + shuffled_list-accounting = accounting; + + return shuffled_list; +} + +EAPI Eina_List * eina_list_merge(Eina_List *left, Eina_List *right) { unsigned int n_left, n_right; diff --git a/src/lib/eina/eina_types.h b/src/lib/eina/eina_types.h index d74d200..d37b20f 100644 --- a/src/lib/eina/eina_types.h +++ b/src/lib/eina/eina_types.h @@ -334,6 +334,21 @@ typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2); #define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function) /** + * @typedef Eina_Random_Cb + * Function used in shuffling functions. An integer betwen min and max + * inclusive must be returned. + * + * @since 1.8 + */ +typedef int (*Eina_Random_Cb)(const int min, const int max); + +/** + * @def EINA_RANDOM_CB + * Macro to cast to Eina_Random_Cb. + */ +#define EINA_RANDOM_CB(function) ((Eina_Random_Cb)function) + +/** * @typedef Eina_Each_Cb * A callback type used when iterating over a container. */ diff --git a/src/tests/eina/eina_test_list.c