commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Yu <j...@scioworks.com>
Subject [lang] MapUtils.swapsKeysValues()
Date Thu, 19 Sep 2002 03:30:53 GMT

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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message