template<class Type>
if order = {3,2,1,0} (and length = 4) then will be reversed used for sorting tables on one column
Definition at line 18 of file ApplyOrder.h. Referenced by Impala::Core::Column::ApplyOrder(), Impala::Core::Table::SortOnColumn1(), Impala::Core::Table::SortOnColumn2(), Impala::Core::Table::SortOnColumn3(), Impala::Core::Table::SortOnColumn4(), Impala::Core::Table::SortOnColumn5(), Impala::Core::Table::SortOnColumn6(), Impala::Core::Table::SortOnColumn7(), Impala::Core::Table::SortOnColumn8(), Impala::Core::Table::SortOnColumn9(), and TestApplyOrder(). 00019 { 00020 // order is copied to keep callers code simpler 00021 int* order = new int[length]; 00022 memcpy(order, constOrder, length*sizeof(int)); 00023 00024 int i; 00025 for(i=0 ; i<length ; ++i) 00026 { 00027 if(order[i] != i) 00028 { 00029 // keep swapping until an element is put at the correct position (this will happen!) 00030 int indexFrom = i; 00031 int indexTo = order[i]; 00032 order[i] = i; 00033 Type value = data[indexFrom]; 00034 while(indexFrom != indexTo) 00035 { 00036 Type temp = data[indexTo]; 00037 data[indexTo] = value; 00038 value = temp; 00039 indexFrom = indexTo; 00040 indexTo = order[indexFrom]; 00041 order[indexFrom] = indexFrom; 00042 } 00043 } 00044 } 00045 }
|