Ad
  1. Implemented addition-subtraction swap. Unlike the most obvious solution — XOR swap — it works with double.
  2. In Igloo, it's advisable to compare doubles using EqualsWithDelta in lieu of Equals.
Code
Diff
  • #include <algorithm>
    #include <math.h>
    
    template< class T >
    void Swap( T& a, T& b ) 
    {
     	a = a + b;
    	b = a - b;
    	a = a - b;
    }
    • #include <algorithm>
    • #include <math.h>
    • template< class T >
    • void Swap( T& a, T& b ) { std::swap( a, b ); }
    • void Swap( T& a, T& b )
    • {
    • a = a + b;
    • b = a - b;
    • a = a - b;
    • }