commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <grahamdavid1...@yahoo.com>
Subject Re: [collections] CaseInsensitiveHashMap
Date Sat, 03 Jan 2004 16:45:38 GMT

--- Stephen Colebourne <scolebourne@btopenworld.com> wrote:
> From: "Phil Steitz" <phil@steitz.com>
> > >>Could be I was being too lazy.  Since toLower() is "idempotent"
> (calling
> > >>it repeatedly has same effect as calling it just once) it "works" to
> just
> > >>override convert(), since in AbstractHashedMap, get, put, remove,
> > >>containsKey, all start by converting the key (nice!).  All I did was
> to
> > >>extend HashedMap and override convert to return
> > >>key.toString().toLowerCase().  The effect is that you actually store
> all
> > >>lower case strings as keys (or null, once I fix this). The behavior
> should
> > >>be the same as the impl that David Graham posted with PR #24537
> (unless
> I
> > >>am missing something -- quite possible).
> > >
> > > This impl will work, but I would prefer to see the case of the key
> > > maintained, just the comparison to be case insensitive.
> >
> > Why exactly?  Would you expect equals to distinguish
> > CaseInsensitiveHashMaps that differ only on key case?
> 
> Well CaseInsensitive as a name doesn't imply to me that it changes
> anything.
> It implies that is compares insenstively (including equals, which should
> be
> handled). This map would be a LowerCaseKeyMap or some such.
> 
> It strikes me that if I put a key in one way, I should get it back that
> way
> too.

It's not a big deal to me whether or not the keys are permanently lower
cased but your reasons for not doing so are sound.  
> 
> BTW: the names now exclude 'Hash' as much as possible, hence it would be
> CaseInsensitiveMap

Just out of curiosity, why are you leaving Hash out of the names?  The
Java idiom seems to be to indicate a collection's implementation in the
name.  Even the standard WeakHashMap maintains the "Hash" portion of the
name.  I'm not particularly tied to CaseInsensitiveHashMap but I chose
that name based on current Java practices.

David

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


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

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


Mime
View raw message