]> git.donarmstrong.com Git - genome.git/commitdiff
redfine swap to use typeof instead
authorDon Armstrong <don@donarmstrong.com>
Fri, 28 Mar 2014 20:59:53 +0000 (13:59 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 28 Mar 2014 20:59:53 +0000 (13:59 -0700)
genome.cpp

index 9924018052c845a7bac3e6d7f06bc4fe36fe07da..f50dd9285065da96bd346aa727e43f1cd3901a81 100644 (file)
@@ -77,7 +77,7 @@ static int BUFFER=1500;
 static int INCREMENT=1000;\r
 \r
 #define BLOCKSIZE   128\r
-#define SWAP(tmp,a,b)  tmp=a; a=b; b=tmp;\r
+#define SWAP(x,y) do {typeof(x) temp##x##y = x; x = y; y = temp##x##y; } while (0)\r
 \r
 static vector< vector< vector<bool> > > chromosome;\r
 static int * fragmentLength;\r
@@ -174,18 +174,15 @@ void FreeIntPtrMatrix(int *** & matrix, int rows){
    \r
 void NewGeneration(){\r
        \r
-   int *** ptrmatrix, * vector;\r
-   bool * boolvector;\r
-   \r
 //    for(int i=0;i<maxN;i++){\r
 //     if(parent_flags[i])printf("numBlock=%d parent=%d first=%d last=%d\n",numBLOCKs,i,parent_First[i],parent_Last[i]);   \r
 //    }\r
    \r
-   SWAP(ptrmatrix, children, parents);\r
-   SWAP(vector, child_First, parent_First);\r
-   SWAP(vector, child_Last, parent_Last);\r
-   SWAP(boolvector, child_flags, parent_flags);\r
-   SWAP(vector, cblocks, pblocks);\r
+   SWAP(children, parents);\r
+   SWAP(child_First, parent_First);\r
+   SWAP(child_Last, parent_Last);\r
+   SWAP(child_flags, parent_flags);\r
+   SWAP(cblocks, pblocks);\r
    \r
    if(!noChange){\r
           currentProfile++;\r