// static void recommender_mock_storage::mix_relation( const relation_type& from, relation_type& to) { for (relation_type::const_iterator it = from.begin(); it != from.end(); ++it) { to[it->first] = it->second; } }
//static void recommender_mock_storage::update_relation_key(const sfv_t& from, const sfv_t& to, relation_type& relmap) { relation_type::iterator it = relmap.find(from); if (it != relmap.end()) { relation_type::mapped_type val; val.swap(it->second); relmap.erase(it); relmap[to].swap(val); } else { relmap[to]; // add default value } }
//static void recommender_mock_storage::get_relation(const sfv_t& query, const relation_type& relmap, size_t ret_num, vector<pair<string, float> >& ids) { ids.clear(); relation_type::const_iterator it = relmap.find(query); if (it != relmap.end()) { ids = it->second; } if (ids.size() > ret_num) { ids.resize(ret_num); } }