FEI Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
fei_CommMap.hpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright 2009 Sandia Corporation. */
3/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4/* non-exclusive license for use of this work by or on behalf */
5/* of the U.S. Government. Export of this program may require */
6/* a license from the United States Government. */
7/*--------------------------------------------------------------------*/
8
9#ifndef _fei_CommMap_hpp_
10#define _fei_CommMap_hpp_
11
12#include <fei_macros.hpp>
13#include <fei_ArrayUtils.hpp>
14#include <set>
15#include <map>
16
17namespace fei {
18
20template<typename T>
21struct CommMap {
22 typedef std::map<int,std::vector<T> > Type;
23};
24
31template<typename T>
32void addItemsToCommMap(int proc, size_t numItems, const T* items,
33 typename CommMap<T>::Type& comm_map,
34 bool keep_sorted_and_unique = true)
35{
36 typename CommMap<T>::Type::iterator iter = comm_map.find(proc);
37 if (iter == comm_map.end()) {
38 iter = comm_map.insert(std::make_pair(proc,std::vector<T>())).first;
39 }
40
41 std::vector<T>& comm_items = iter->second;
42
43 if (keep_sorted_and_unique) {
44 for(size_t i=0; i<numItems; ++i) {
45 fei::sortedListInsert(items[i], comm_items);
46 }
47 }
48 else {
49 for(size_t i=0; i<numItems; ++i) {
50 comm_items.push_back(items[i]);
51 }
52 }
53}
54
55} //namespace fei
56
57#endif // _fei_CommMap_hpp_
58
void addItemsToCommMap(int proc, size_t numItems, const T *items, typename CommMap< T >::Type &comm_map, bool keep_sorted_and_unique=true)
int sortedListInsert(const T &item, std::vector< T > &list)
std::map< int, std::vector< T > > Type