Just tried to do it using a do/while but it is not convenient du to the fact that `index = nextSlot(index, mask)` needs to be called between every iteration.