You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by John Yu <jo...@scioworks.com> on 2002/09/19 09:52:10 UTC

[collection] Re: [lang] MapUtils.swapsKeysValues()

Doh! Prefixed the post with the wrong sub-package name...

At 11:30 am 19-09-2002, you wrote:

>I'd like to propose a very sample addition to MapUtils, a method to swap 
>keys and values.
>I have a few use cases requiring this. I wanted to scratch my itch. :-)
>
>
>   static public void swapKeysValues(Map source, Map dest) {
>     Iterator iter = source.entrySet().iterator();
>
>     while(iter.hasNext()) {
>       Map.Entry entry = (Map.Entry) iter.next();
>       dest.put(entry.getValue(), entry.getKey());
>     }
>   }

-- 
John Yu                       Scioworks Technologies
e: john@scioworks.com         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>