Hey,
I have a class which uses a HashSet
and I want the class implement Iterable
, I do not, however, want the class iterator to support the remove()
method.
The default iterator of HashSet
is HashSet.KeyIterator
which is a private class within the HashSet
class, so I cannot simply extend it and override the remove method.
Ideally I would like to avoid writing a wrapper class for KeyIterator
, but I am at a loss as to how else I could easily and simply implement my own iterator in any other way.
Any ideas?
Cheers,
Pete