MAP

#include <map>

struct key

{

    std::string group;

    std::string user;

 

    inline void clear()

    {

        group.clear();

        user.clear();

    }

    inline std::string buildKey()

    {

        std::ostringstream os;

        os << group << user;

        std::string key = os.str();

        return key;

    }

};

 

student Value

{

    double wages;

};

std::map<key, value> m_personalWages;

 

key plute;

std::map<key, value>::iterator cit = m_personalWages.lower_bound(key);

if(cit != m_personalWages.end() &&! m_personalWages.key_comp()(key, cit->first))

{

   cit->second.wages  += wages;

}

else

{

    std::m_personalWages.insert(cit, value_type(key, wages));

    // m_personalWages.insert(std::make_pair(key,Wages));

}

 

posted @ 2016-08-24 21:35  山涧的水  阅读(110)  评论(0)    收藏  举报