#ifndef _COMMON_QUICKSORT_TPP_ #define _COMMON_QUICKSORT_TPP_ template QuickSort::QuickSort(void) : mlpItemList(0), mlpBlockItems(0) { } template QuickSort::~QuickSort() { } template void QuickSort::sortItems(Array &arrayItems,SortOptions::SortOrder sortOrder) { if(!arrayItems.size())return; mlpItemList=&arrayItems[0]; if(SortOptions::Ascending==sortOrder)quickSort(0,arrayItems.size()-1); else quickSortDescending(0,arrayItems.size()-1); } template void QuickSort::sortItems(Block &someBlock,SortOptions::SortOrder sortOrder) { if(!someBlock.size())return; mlpBlockItems=&someBlock; if(SortOptions::Ascending==sortOrder)sortBlockAscending(0,someBlock.size()-1L); else sortBlockDescending(0,someBlock.size()-1L); } template void QuickSort::quickSort(long left,long right) { long tempLeft(left); long tempRight(right); T tempItem; T swapItem; tempItem=*((T FAR*)(mlpItemList+((left+right)/2L))); do{ while(*((T FAR*)(mlpItemList+tempLeft))=left)tempRight--; if(tempLeft>right)tempLeft--; if(tempRight void QuickSort::quickSortDescending(long left,long right) { long tempLeft(left); long tempRight(right); T tempItem; T swapItem; tempItem=*((T FAR*)(mlpItemList+((left+right)/2L))); do{ while(*((T FAR*)(mlpItemList+tempLeft))>tempItem&&tempLeft<=right)tempLeft++; while(tempItem>*((T FAR*)(mlpItemList+tempRight))&&tempRight>=left)tempRight--; if(tempLeft>right)tempLeft--; if(tempRight void QuickSort::sortBlockAscending(long left,long right) { long tempLeft(left); long tempRight(right); T tempItem; T swapItem; tempItem=(*mlpBlockItems)[(left+right)/2L]; do{ while((*mlpBlockItems)[tempLeft]=left)tempRight--; if(tempLeft>right)tempLeft--; if(tempRight void QuickSort::sortBlockDescending(long left,long right) { long tempLeft(left); long tempRight(right); T tempItem; T swapItem; tempItem=(*mlpBlockItems)[(left+right)/2L]; do{ while((*mlpBlockItems)[tempLeft]>tempItem&&tempLeft<=right)tempLeft++; while(tempItem>(*mlpBlockItems)[tempRight]&&tempRight>=left)tempRight--; if(tempLeft>right)tempLeft--; if(tempRight