I think that there is something wrong with the iterators of Hashtables.

Perhaps it is my misconception, but shouldn't I get an iterator that returns the objects present in a map when I request an iterator over its entry set?

To be more specific, assume the following example (in jpython for the sake of convenience):
>>> import java
>>> ht = java.util.Hashtable()
>>> ht.put( 'a', 'b' )
>>> it = ht.entrySet().iterator()
>>> n = it.next()
>>> n
a=b
>>> n.getClass()
<jclass java.util.Hashtable$Entry at -289078028>

However, keySet().iterator()  returns an iterator that allows me to access the real key-Objects!!!

As it is obvious, the iterator returns objects that belong to a class that is not editable.
Shouldn't it return the objects that I have put it?
That is, reading the specs in the documentation, I expect to receive functionality similar to the functionality of an Enumeration over the Hashtable elements (plus some thread-safety for my iteration, which is the only real reason to use an Iterator and not an Enumeration).

Is this a bug or my misconception?
If this isn't really a bug, I think then the documentation is totally screwed up and we receive a totally useless Iterator object!!!

Thanx in advance.

-- dimitris [mailto:[EMAIL PROTECTED]]
 


Reply via email to