Count and dispose functions for the hashset.