Ejemplo n.º 1
0
//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
  }
}
Ejemplo n.º 2
0
//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);
  }
}