#include "globals.hh"
Go to the source code of this file.
Functions | |
void | sort_double (G4double[], G4int, G4int) |
void | swap_double (G4double[], G4int, G4int) |
Definition at line 39 of file G4Sort.cc.
References sort_double(), and swap_double().
Referenced by G4CylindricalSurface::Intersect(), G4ConicalSurface::Intersect(), and sort_double().
00040 { 00041 // G4Sort elements in array from v[left] to v[right] 00042 // used recursively 00043 // algorithm comes from Kernighan and Ritchie, "The C Programming 00044 // Language", second edition, p.87 00045 00046 G4int i, last; 00047 if ( left >= right ) // do nothing if array contains 00048 return; // fewer than two elements 00049 00050 swap_double( v, left, ( left + right ) / 2 ); // move part. elt. 00051 last = left; // to v[0] 00052 00053 for ( i = left+1; i <= right; i++ ) // partition 00054 if ( v[i] < v[left] ) 00055 swap_double( v, ++last, i ); 00056 00057 swap_double( v, left, last ); // restore partition element 00058 00059 sort_double( v, left, last-1 ); 00060 sort_double( v, last+1, right ); 00061 return; 00062 }
Definition at line 65 of file G4Sort.cc.
Referenced by sort_double().
00066 { 00067 /* interchange elements i and j in an array */ 00068 G4double temp; 00069 temp = v[i]; 00070 v[i] = v[j]; 00071 v[j] = temp; 00072 }