Merge pull request #1382 from airspeedswift/remove-indexdistance

Make algorithms generic over IndexDistance