diff options
author | Sergei Golubchik <sergii@pisem.net> | 2010-11-25 18:17:28 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2010-11-25 18:17:28 +0100 |
commit | 65ca700def99289cc31a7040537f5aa6e12bf485 (patch) | |
tree | 97b3a07299b626c519da0e80c122b5b79b933914 /sql/sql_list.h | |
parent | 2ab57de38d13d927ddff2d51aed4af34e13998f5 (diff) | |
parent | 6e5bcca7935d3c62f84bb640e5357664a210ee12 (diff) | |
download | mariadb-git-65ca700def99289cc31a7040537f5aa6e12bf485.tar.gz |
merge.
checkpoint.
does not compile.
Diffstat (limited to 'sql/sql_list.h')
-rw-r--r-- | sql/sql_list.h | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/sql/sql_list.h b/sql/sql_list.h index 5cd24236644..78549b73cef 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -54,7 +54,7 @@ public: static void operator delete[](void *ptr, MEM_ROOT *mem_root) { /* never called */ } static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } -#ifdef HAVE_purify +#ifdef HAVE_valgrind bool dummy; inline Sql_alloc() :dummy(0) {} inline ~Sql_alloc() {} @@ -521,6 +521,43 @@ public: /* + Exchange sort algorithm for List<T>. +*/ +template <class T> +inline void exchange_sort(List<T> *list_to_sort, + int (*sort_func)(T *a, T *b, void *arg), void *arg) +{ + bool swap; + List_iterator<T> it(*list_to_sort); + do + { + T *item1= it++; + T **ref1= it.ref(); + T *item2; + + swap= FALSE; + while ((item2= it++)) + { + T **ref2= it.ref(); + if (sort_func(item1, item2, arg) < 0) + { + T *item= *ref1; + *ref1= *ref2; + *ref2= item; + swap= TRUE; + } + else + { + item1= item2; + ref1= ref2; + } + } + it.rewind(); + } while (swap); +} + + +/* A simple intrusive list which automaticly removes element from list on delete (for THD element) */ |