What is "Map<C,K,V>" here? The Map interface only has two type parameters, right? Shouldn't it just be Map<K,V>?
On 8/29/07, Stephen Kestle <[EMAIL PROTECTED]> wrote: > > Hi John, > > I have not opened a ticket yet, but ... I have had very similar > requirements, and will [most-likely] be putting something in that will solve > your problem. > > However, it will not be a class - consider this method > > Map<C, K,V> CollectionUtils.toMap(Collection<C> input, Transformer<C,K> > keyTransformer, Transformer<C,V> valueTransformer, Map<K,V> map) > > You could then do what you wanted, passing in your integer transformer for > the key, and potentially MultiHashMap for the map. > > NB - this is in an ideal (and we're heading to that) collections world. > MultiHashMap will need to be changed to extend map properly and implement > the interface in a consistent way (not breaking Map contract etc). > > Also note that there will be other variations on the method - most > commonly > > Map<K,V> CollectionUtils.toMap(Collection<V> input, Transformer<V,K> > keyTransformer){ > return toMap(input, keyTransformer, NOPTransformer, new > HashMap<K,V>()); > } > > I'll raise a ticket within the next few days - watch this list! > > Cheers > > Stephen > > John wrote: > > Hi, > > I'm new to the collections mailing list and I have a class I think would > be appropriate to be donated to the collections API. > > This is an extension of the MultiHashMap and filters a given Collection by > a given field. It will put the objects into the map using the field value as > the key. > > For example, lets say I have a class X which has an integer i. I have four > instances of X each with the following names and values of i. > > x1 i=1 > x2 i=2 > x3 i=2 > x4 i=5 > > The resulting MultiHashMap will contain the following after a call to > sortCollection(X.class, "i"); has been made. > > key | Objects > 1 | x1 > 2 | x2, x3 > 5 | x4 > > I can then get a Collection of sorted objects by asking the map for the > key value. I find this very useful in many situations I have come across. I > will of course make the required doc, package and src formatting changes to > the class before submitting it. > > Please can you take a look and tell me if it is worth committing this to > the Collections repository. What is the process I need to go through before > committing? I'm a bit pressed for time at the mo' so I can't really spend > too much time working on the Collections API as a regular developer. I am a > big fan of the commons Collections API and commons project in general, just > wish I had more time to get involved. > > Kind regards, > > John Hunsley. > Technical Supervisor, Cy-nap Ltd. > > ------------------------------ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- > ------------------------------ > * <http://www.orionhealth.com>* > > *Stephen Kestle Software Engineer* > [EMAIL PROTECTED] > P: +64 9 638 0619 > M: +64 27 453 7853 > F: +64 9 638 0699 > S: skestle > www.orionhealth.com > > This e-mail and any attachments are intended only for the person to whom > it is addressed and may contain privileged, proprietary, or other data > protected from disclosure under applicable law. If you are not the addressee > or the person responsible for delivering this to the addressee you are > hereby notified that reading, copying or distributing this transmission is > prohibited. If you have received this e-mail in error, please telephone us > immediately and remove all copies of it from your system. Thank you for your > co-operation. >