mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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
This commit is contained in:
@ -442,6 +442,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)
|
||||
|
Reference in New Issue
Block a user