FEI Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
fei_SharedIDs.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_SharedIDs_hpp_
10#define _fei_SharedIDs_hpp_
11
12#include <fei_macros.hpp>
13
14#include <vector>
15#include <set>
16#include <map>
17
18namespace fei {
19
21 template<typename T>
22 class SharedIDs {
23 public:
27 {}
28
32 {}
33
35 virtual ~SharedIDs() {}
36
38 typedef std::map<T,std::set<int> > map_type;
39
45 void addSharedID(const T& ID, size_t numSharingProcs, const int* sharingProcs)
46 {
47 typename map_type::iterator iter = sharedIDs_.find(ID);
48 if (iter == sharedIDs_.end()) {
49 iter = sharedIDs_.insert(std::make_pair(ID,std::set<int>())).first;
50 }
51 for(size_t i=0; i<numSharingProcs; ++i) {
52 iter->second.insert(sharingProcs[i]);
53 }
54 }
55
58
60 const map_type& getSharedIDs() const { return( sharedIDs_ ); }
61
64 std::vector<int>& getOwningProcs() { return( owningProcs_ ); }
65
68 const std::vector<int>& getOwningProcs() const { return( owningProcs_ ); }
69
70 private:
72 std::vector<int> owningProcs_;
73 };
74
75} //namespace fei
76
77#endif // _fei_SharedIDs_hpp_
78
map_type & getSharedIDs()
map_type sharedIDs_
std::vector< int > & getOwningProcs()
std::map< T, std::set< int > > map_type
void addSharedID(const T &ID, size_t numSharingProcs, const int *sharingProcs)
virtual ~SharedIDs()
std::vector< int > owningProcs_
const map_type & getSharedIDs() const
SharedIDs(const SharedIDs< T > &src)
const std::vector< int > & getOwningProcs() const