From 552c2aa5e5900697e3f2bcc38dc381662af5b8d6 Mon Sep 17 00:00:00 2001
From: michaelld <michaelld@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Tue, 6 Feb 2007 23:26:05 +0000
Subject: Added explicit template instantiation. Removed unneeded non-template
 code.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4400 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gr-trellis/src/lib/quicksort_index.cc | 77 +++++++++++++----------------------
 1 file changed, 28 insertions(+), 49 deletions(-)

(limited to 'gr-trellis/src/lib/quicksort_index.cc')

diff --git a/gr-trellis/src/lib/quicksort_index.cc b/gr-trellis/src/lib/quicksort_index.cc
index cffab8e02c..0b577ff053 100644
--- a/gr-trellis/src/lib/quicksort_index.cc
+++ b/gr-trellis/src/lib/quicksort_index.cc
@@ -22,68 +22,47 @@
 
 #include "quicksort_index.h"
 
-template <class T> void SWAP (T & a, T & b)
+template <class T>
+void
+SWAP
+(T & a, T & b)
 {
-T temp=a;
-a=b;
-b=temp;
+  T temp = a;
+  a = b;
+  b = temp;
 }
 
-
-// standard quicksorting but also return the indices of the sorted data
-// don't know how to make it work with swig...
-template <class T> void quicksort_index(std::vector<T> & p, std::vector<int> & index, int left, int right)
+template <class T>
+void
+quicksort_index
+(std::vector<T> & p, std::vector<int> & index, int left, int right)
 {
-
-if (left < right) {
+  if (left < right) {
     int i = left;
     int j = right + 1;
     T pivot = p[left];
     do {
-        do 
-            i++;
-        while ((p[i] < pivot) && (i < right));
-        do 
-            j--;
-        while ((p[j] > pivot) && (j > left));
-        if (i < j) {
-            SWAP <T> (p[i],p[j]);
-            SWAP <int> (index[i],index[j]);
-        }
+      do
+	i++;
+      while ((p[i] < pivot) && (i < right));
+      do
+	j--;
+      while ((p[j] > pivot) && (j > left));
+      if (i < j) {
+	SWAP <T> (p[i],p[j]);
+	SWAP <int> (index[i],index[j]);
+      }
     } while (i < j);
     SWAP <T> (p[left], p[j]);
     SWAP <int> (index[left], index[j]);
     quicksort_index <T> (p,index, left, j-1);
     quicksort_index <T> (p,index, j+1, right);
+  }
 }
-}
-
-
-
-// Same as above (only works for int data)
-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);
-}
-}
+// instantiate an <int> version of the quicksort_index
 
+template
+void
+quicksort_index<int>
+(std::vector<int> & p, std::vector<int> & index, int left, int right);
-- 
cgit v1.2.3