diff options
author | anastas | 2006-08-11 10:27:46 +0000 |
---|---|---|
committer | anastas | 2006-08-11 10:27:46 +0000 |
commit | 8e8f22dda66b63ee58a25f1052cd197779f164dc (patch) | |
tree | c4c317c44a7c2984f846f54153a3470656f69e9e /gr-trellis/src/lib/quicksort_index.cc | |
parent | 954e2976e43507479e0bc5d1526e555627117125 (diff) | |
download | gnuradio-8e8f22dda66b63ee58a25f1052cd197779f164dc.tar.gz gnuradio-8e8f22dda66b63ee58a25f1052cd197779f164dc.tar.bz2 gnuradio-8e8f22dda66b63ee58a25f1052cd197779f164dc.zip |
Added support for concatenated codes
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3234 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-trellis/src/lib/quicksort_index.cc')
-rw-r--r-- | gr-trellis/src/lib/quicksort_index.cc | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/gr-trellis/src/lib/quicksort_index.cc b/gr-trellis/src/lib/quicksort_index.cc index 705aeebed..0ab63ebbe 100644 --- a/gr-trellis/src/lib/quicksort_index.cc +++ b/gr-trellis/src/lib/quicksort_index.cc @@ -29,14 +29,14 @@ a=b; b=temp; } + template <class T> void quicksort_index(std::vector<T> & p, std::vector<int> & index, int left, int right) { -T pivot; if (left < right) { int i = left; int j = right + 1; - pivot = p[left]; + T pivot = p[left]; do { do i++; @@ -51,7 +51,36 @@ if (left < right) { } while (i < j); SWAP <T> (p[left], p[j]); SWAP <int> (index[left], index[j]); - quicksort_index(p,index, left, j-1); - quicksort_index(p,index, j+1, right); + quicksort_index <T> (p,index, left, j-1); + quicksort_index <T> (p,index, j+1, right); +} +} + + + +void quicksort_index1(std::vector<int> & p, std::vector<int> & index, int left, int right) +{ + +if (left < right) { + int i = left; + int j = right + 1; + int pivot = p[left]; + do { + do + i++; + while ((p[i] < pivot) && (i < right)); + do + j--; + while ((p[j] > pivot) && (j > left)); + if (i < j) { + SWAP <int> (p[i],p[j]); + SWAP <int> (index[i],index[j]); + } + } while (i < j); + SWAP <int> (p[left], p[j]); + SWAP <int> (index[left], index[j]); + quicksort_index1 (p,index, left, j-1); + quicksort_index1 (p,index, j+1, right); } } + |