commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael A. Smith" <mich...@iammichael.org>
Subject Re: [Collections] Comment on LRUMap.removeLRU()
Date Thu, 14 Feb 2002 23:12:07 GMT
On Thu, 14 Feb 2002, Morgan Delagrange wrote:

> ----- Original Message -----
> From: "Morgan Delagrange" <mdelagra@yahoo.com>
> To: "Jakarta Commons Developers" <commons-dev@jakarta.apache.org>
> Sent: Thursday, February 14, 2002 4:56 PM
> Subject: [Collections] Comment on LRUMap.removeLRU()
> 
> 
> > Seems like an odd method (besides the fact that it didn't actually work
> > until this week ;)  It returns the key of the Object that was removed from
> > the Map.  Don't you think it should return both the key and the value,
> > perhaps as an Object[] array?  After all, you have no way to use that key;
> > the value is already gone.

Why not Map.Entry?  :)

> >
> > Technically, there's nothing we can do about it until Collections 2.x, but
> > maybe in the Javadocs we should announce an intention to deprecate it for
> a
> > more appropriate call?
> >
> 
> Correction.  We could actually deprecate it now and provide an alternative
> for the 1.1 release.  Any reason not to?

Don't think so, as long as the deprecated method remains supported through 
1.x.  Although if it didn't work until this week, I doubt anyone was 
using/relying on it in the first place.  


Another option that might be useful is to add a protected method, taking
both the key and value as arguments, that's called when an element is
removed.  Rather than having subclasses override the "removeLRU" method, 
they would override this method and process it appropriately.  

For example:

protected void processRemovedLRU(Object key, Object value) {
}

This might actually be safer for subclasses since they don't actually need 
to do the remove.  

Aaron Smuts has a similar method in his LRU cache in Stratum, but his only
takes one argument (an Object, but it looks like the object that is passed
in is an ILRUElement, which is very similar to a Map.Entry).  He named his
"waterfall".

http://cvs.apache.org/viewcvs.cgi/jakarta-turbine-stratum/src/java/org/apache/stratum/util/lru/LRUStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup


regards,
Michael


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message