예제 #1
0
void addItemsToCommMap(int proc, size_t numItems, const T* items,
                       typename CommMap<T>::Type& comm_map,
                       bool keep_sorted_and_unique = true)
{
  typename CommMap<T>::Type::iterator iter = comm_map.find(proc);
  if (iter == comm_map.end()) {
    iter = comm_map.insert(std::make_pair(proc,std::vector<T>())).first;
  }

  std::vector<T>& comm_items = iter->second;

  if (keep_sorted_and_unique) {
    for(size_t i=0; i<numItems; ++i) {
      fei::sortedListInsert(items[i], comm_items);
    }
  }
  else {
    for(size_t i=0; i<numItems; ++i) {
      comm_items.push_back(items[i]);
    }
  }
}