These APIs allow one to write code that is agnostic of whether it is using an ArrayHashMap or a HashMap, which can be valuable. Specify intent precisely: if you only need the count of the items, it makes sense to have a function for that.