$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] Does Boost has an utility to replace all OLD Keys with NEW one for MultiMap/Map?
From: Tushar Chowdhury (tchowdhury80_at_[hidden])
Date: 2009-05-07 04:09:47
Hi Guys,
As of now I failed to get such an algo. I've come up with an proposed
solution. Please verify:
namespace Boost{
template <typename CONTAINER>
   void replace_key(CONTAINER& container,
                    const typename CONTAINER::key_type& oldKey,
                    const typename CONTAINER::key_type& newKey)
   {
       typename CONTAINER::iterator begin(container.find(oldKey));
       for(;;){
           if(begin != container.end()){
               container.insert(typename CONTAINER::value_type(newKey,
begin->second));
               container.erase(begin++);
               begin = container.find(oldKey);
           }
           else{
               return;
           }
       }
   }
}
make sense?