This is probably a premature optimisation -- the HashSet class has an isEmpty() method which should be fast enough.