An efficient swap algorithm for the lattice Boltzmann method