0001 template <typename T> void Vector<T>::shellSort(Rank lo, Rank hi) { 0002 for (Rank d = 0x7FFF; 0 < d; d >>= 1) //PS Sequence: { 1, 3, 7, 15, 31, ... } 0003 for (Rank j = lo + d; j < hi; j++) { //for each j in [lo+d, hi) 0004 T x = _elem[j]; Rank i = j; //within the prefix of the subsequence of [j] 0005 while ((lo+d <= i) && (x < _elem[i-d])) //find the appropriate 0006 _elem[i] = _elem[i-d], i -= d; //predecessor [i] 0007 _elem[i] = x; //where to insert [j] 0008 } 0009 } //shellSort