diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2009-09-01 00:02:09 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2009-09-01 00:02:09 +0400 |
commit | d762bf21cc0fa7a96b7135b4d5cf716d15a32fc8 (patch) | |
tree | 03d5085bbb778a68766cec13706559c049ffb6bf /sql/sql_list.h | |
parent | 005c24e9739f1050e846cef8a3e75c4671b30a7b (diff) | |
download | mariadb-git-d762bf21cc0fa7a96b7135b4d5cf716d15a32fc8.tar.gz |
MWL#17: Table-elimination
- Addressing review feedback, generation 4.
include/my_global.h:
Make ALIGN_PTR's action correspond to that of ALIGN_SIZE
sql/item.cc:
MWL#17: Table-elimination
- Review feedback: function renames, better comments
sql/item.h:
MWL#17: Table-elimination
- Review feedback: function renames, better comments
sql/item_cmpfunc.cc:
MWL#17: Table-elimination
- Review feedback: function renames, better comments
sql/item_subselect.cc:
MWL#17: Table-elimination
- Review feedback: function renames, better comments
sql/item_subselect.h:
MWL#17: Table-elimination
- Review feedback: function renames, better comments
sql/opt_table_elimination.cc:
MWL#17: Table-elimination
- Addressing review feedback, generation 4: abstract everything in case
we would need to change it for something else in the future.
sql/sql_list.h:
MWL#17: Table-elimination
- Introduce exchange_sort(List<T> ...) template function
sql/sql_select.cc:
MWL#17: Table-elimination
- Review feedback: function renames, better comments
Diffstat (limited to 'sql/sql_list.h')
-rw-r--r-- | sql/sql_list.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sql/sql_list.h b/sql/sql_list.h index 6edf9a00b87..eb580120c1b 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -443,6 +443,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) */ |