Thanks for the patch, Costin.  I've applied it to the commons collections
(and to Struts, which still uses its own private copy of these).  Could
you try the new ones to make sure that they work for you?

On the general issue of "why extend TreeMap instead of just implement
SortedMap", the reasoning was that some people don't think ahead, and
they've defined their method calling sequences using TreeMap instead of
Map or SortedMap as the parameter type.  Using a subclass makes it easier
to use the "fast" version (if it is appropriate), without having to change
all the calling sequences all at once.

Implementing SortedMap instead would still not solve the problem of what
happens if new method signatures are added later (although the compiler
would catch it in this case :-).  You still need to update these classes
to stay current with the most recent JDK -- the code is still backwards
compatible to older JDKs as long as the method signature differences are
additions, not removals.

Craig


On Fri, 18 May 2001, Cozianu, Costin wrote:

> Hello all,
> 
> I'm not sure if it is important, but my Visual Age for java complains that
> Iterator is not visible in FastTreeMap.java because 
> there also exists a private Iterator inner class in the base class TreeMap,
>  so the compiler gets confused.
> 
> Yes , you can blame it on the compiler but
> I know there are a lot of people that use VAJava, therefore I think that
> maybe it's
> worth making this little modification so we don't have to make it
> by hand every time we import the jakarta-collections in VAJava.
> 
> Speeking of FastTreeMap.java, I am confused why it needs to inherit from
> TreeMap.
> The SortedMap functionality is completely implemented by delegation so
> inheriting
> from TreeMap looks rather unnecessary.
> 
> The same situation with FastArrayList, FastHashMap. It's not that big of a
> deal but if tommorrow 
> Sun issue a JDK 1.4 and adds something to Map for example, and of course
> implemented in HashMap,
> then FastHashMap will still compile beautifully but will produce incorrect
> results at run-time.
> 
> My idea is that maybe it's useful to declare only FastTreeMap implements
> Sortedmap
> and the equivalent for other types.
> 
> Costin
> 
> cvs diff FastTreeMap.java (in directory
> C:\costin\open-source\jakarta\jakarta-commons\collections\src\java\org\apach
> e\commons\collections\)
> Index: FastTreeMap.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-commons/collections/src/java/org/apache/commons/coll
> ections/FastTreeMap.java,v
> retrieving revision 1.3
> diff -r1.3 FastTreeMap.java
> 323c323
> <             Iterator i = map.entrySet().iterator();
> ---
> >             java.util.Iterator i = map.entrySet().iterator();
> 341c341
> <                 Iterator i = map.entrySet().iterator();
> ---
> >                 java.util.Iterator i = map.entrySet().iterator();
> 407c407
> <             Iterator i = map.entrySet().iterator();
> ---
> >             java.util.Iterator i = map.entrySet().iterator();
> 414c414
> <                 Iterator i = map.entrySet().iterator();
> ---
> >                 java.util.Iterator i = map.entrySet().iterator();
> 

Reply via email to