Statistical mechanics of hard ellipsoids. I. Overlap algorithm and the contact function