include <algorithm> for std::swap

This avoids compile error on OS X 10.8 with libstdc++