41 #ifndef EPETRAEXT_DIRECTORY_H
42 #define EPETRAEXT_DIRECTORY_H
51 #include <Teuchos_RCP.hpp>
53 #include <EpetraExt_Functors.h>
60 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
66 typedef typename std::map< KT, Teuchos::RCP<DT> >
DataMap;
70 typedef typename std::multimap< KT, Teuchos::RCP<DT> >
DataRecvMap;
104 bool operator==(
const Directory & )
const;
105 bool operator!=(
const Directory & )
const;
139 template <
typename T>
142 int operator()(
const T & in ) { assert(0);
return 0; }
153 : size_( static_cast<double>(size) )
158 int slen = in.length();
160 for(
int i = 0; i < slen; ++i )
161 sum += static_cast<int>( in[i] );
163 return static_cast<int>( fmod( static_cast<float>( sum ), size_ ) );
170 template <
typename T,
typename U >
173 typedef typename std::multimap< typename T::value_type, typename U::value_type> UTMultiMap;
177 typename T::iterator iterT = firstContainer.begin();
178 typename T::iterator endT = firstContainer.end();
179 typename U::iterator iterU = secondContainer.begin();
180 typename U::iterator endU = secondContainer.end();
182 for( ; (iterT!=endT)||(iterU!=endU) ; ++iterT, ++iterU )
183 SortMap.insert(
typename UTMultiMap::value_type( *iterT, *iterU ) );
185 firstContainer.clear();
186 secondContainer.clear();
188 typename UTMultiMap::iterator iterUTM = SortMap.begin();
189 typename UTMultiMap::iterator endUTM = SortMap.end();
191 for( ; iterUTM != endUTM; ++iterUTM )
193 firstContainer.push_back( iterUTM->first );
194 secondContainer.push_back( iterUTM->second );
201 template <
typename T >
204 if( container.size() < 2 )
return true;
206 typename T::iterator iterT = container.begin();
207 typename T::iterator endT = container.end();
208 typename T::iterator iterTPlus = iterT;
211 for( ; iterTPlus != endT; ++iterT, ++iterTPlus )
212 if( !(*iterT<*iterTPlus) )
return false;
217 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
226 pushData_( entries, newEntries, procs );
238 for( ; citDM != cendDM; ++citDM )
239 container_.insert( *citDM );
242 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
251 pushKeys_( keys, newKeys, procs );
263 for( ; citKL != cendKL; ++citKL )
264 container_.erase( *citKL );
267 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
278 pushKeys_( keys, newKeys, procs );
285 for( ; citKL != cendKL; ++citKL )
287 if( !container_.count( *citKL ) )
288 throw "Data not in directory: " + *citKL +
"\n";
290 newEntries[*citKL] = (container_.lower_bound( *citKL ))->second;
293 migrate_.rvs( procs, newKeys, newEntries, entries );
299 for( ; citKL != cendKL; ++citKL )
301 if( !container_.count( *citKL ) )
302 throw "Data not in directory: " + *citKL +
"\n";
304 entries[*citKL] = (container_.lower_bound( *citKL ))->second;
312 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
323 for( ; itKL != endKL; ++itKL )
324 procs.push_back( distHash_(*itKL) );
328 migrate_( procs, sKeys, rKeys );
331 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
342 for( ; itDM != endDM; ++itDM )
343 procs.push_back( distHash_(itDM->first) );
345 migrate_( procs, sData, rData );
void pushKeys_(KeyList &, KeyList &, ProcList &)
AC::const_iterator ContainerCIter
std::multimap< KT, Teuchos::RCP< DT > > DataRecvMap
KeyList::iterator KeyListIter
DataRecvMap::const_iterator DataRecvMapCIter
DataRecvMap::iterator DataRecvMapIter
ProcKeyList::iterator ProcKeyListIter
DataMap::iterator DataMapIter
Directory(MG migrate, DH distHash)
std::vector< ProcKeyPair > ProcKeyList
void SortContainer2(T &firstContainer, U &secondContainer)
Sorts a given container: deal with a problem with some STL impl.
DataMap::const_iterator DataMapCIter
std::map< KT, Teuchos::RCP< DT > > DataMap
std::vector< int > ProcList
ProcList::iterator ProcListIter
std::vector< KT > KeyList
void pushData_(DataMap const &, DataRecvMap &, ProcList &)
std::pair< int, KT > ProcKeyPair
bool IsSorted(T &container)
Checks if data in a container is sorted.
AC::iterator ContainerIter
void addEntries(DataMap const &entries)
void getEntries(KeyList &keys, DataMap &entries)
void deleteEntries(KeyList &keys)
KeyList::const_iterator KeyListCIter
int operator()(const std::string &in)
Distributed Directory Tool.