41 #ifndef EPETRAEXT_DIRECTORY_H
42 #define EPETRAEXT_DIRECTORY_H
44 #if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
46 #warning "The EpetraExt package is deprecated"
59 #include <EpetraExt_Functors.h>
66 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
72 typedef typename std::map< KT, Teuchos::RCP<DT> >
DataMap;
76 typedef typename std::multimap< KT, Teuchos::RCP<DT> >
DataRecvMap;
145 template <
typename T>
159 : size_( static_cast<double>(size) )
164 int slen = in.length();
166 for(
int i = 0; i < slen; ++i )
167 sum += static_cast<int>( in[i] );
169 return static_cast<int>( fmod( static_cast<float>( sum ), size_ ) );
176 template <
typename T,
typename U >
179 typedef typename std::multimap< typename T::value_type, typename U::value_type> UTMultiMap;
183 typename T::iterator iterT = firstContainer.begin();
184 typename T::iterator endT = firstContainer.end();
185 typename U::iterator iterU = secondContainer.begin();
186 typename U::iterator endU = secondContainer.end();
188 for( ; (iterT!=endT)||(iterU!=endU) ; ++iterT, ++iterU )
189 SortMap.insert(
typename UTMultiMap::value_type( *iterT, *iterU ) );
191 firstContainer.clear();
192 secondContainer.clear();
194 typename UTMultiMap::iterator iterUTM = SortMap.begin();
195 typename UTMultiMap::iterator endUTM = SortMap.end();
197 for( ; iterUTM != endUTM; ++iterUTM )
199 firstContainer.push_back( iterUTM->first );
200 secondContainer.push_back( iterUTM->second );
207 template <
typename T >
210 if( container.size() < 2 )
return true;
212 typename T::iterator iterT = container.begin();
213 typename T::iterator endT = container.end();
214 typename T::iterator iterTPlus = iterT;
217 for( ; iterTPlus != endT; ++iterT, ++iterTPlus )
218 if( !(*iterT<*iterTPlus) )
return false;
223 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
232 pushData_( entries, newEntries, procs );
244 for( ; citDM != cendDM; ++citDM )
245 container_.insert( *citDM );
248 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
257 pushKeys_( keys, newKeys, procs );
269 for( ; citKL != cendKL; ++citKL )
270 container_.erase( *citKL );
273 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
284 pushKeys_( keys, newKeys, procs );
291 for( ; citKL != cendKL; ++citKL )
293 if( !container_.count( *citKL ) )
294 throw "Data not in directory: " + *citKL +
"\n";
296 newEntries[*citKL] = (container_.lower_bound( *citKL ))->second;
299 migrate_.rvs( procs, newKeys, newEntries, entries );
305 for( ; citKL != cendKL; ++citKL )
307 if( !container_.count( *citKL ) )
308 throw "Data not in directory: " + *citKL +
"\n";
310 entries[*citKL] = (container_.lower_bound( *citKL ))->second;
318 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
329 for( ; itKL != endKL; ++itKL )
330 procs.push_back( distHash_(*itKL) );
334 migrate_( procs, sKeys, rKeys );
337 template <
typename KT,
typename DT,
class DH,
class AC,
class MG>
348 for( ; itDM != endDM; ++itDM )
349 procs.push_back( distHash_(itDM->first) );
351 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
bool operator==(const Directory &) const
DataMap::iterator DataMapIter
bool operator!=(const Directory &) const
Directory(MG migrate, DH distHash)
int operator()(const T &in)
std::vector< ProcKeyPair > ProcKeyList
void SortContainer2(T &firstContainer, U &secondContainer)
Sorts a given container: deal with a problem with some STL impl.
Directory & operator=(const Directory &)
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.