Classes | Functions
libMesh::Parallel::Utils Namespace Reference


struct  Convert
 A utility to convert a double to some sort of KeyType, for interpreting how histogram bounds relate to KeyType positions. More...
struct  Convert< Hilbert::HilbertIndices >
struct  Convert< std::pair< FirstKeyType, SecondKeyType > >
 A pseudoinverse for converting bounds back to pairs of key types. More...


template<typename KeyType >
bool is_sorted (const std::vector< KeyType > &v)
template<typename KeyType >
double to_double (const KeyType &k)
 A utility function which converts whatever KeyType is to a double for the histogram bounds. More...
template<typename FirstKeyType , typename SecondKeyType >
double to_double (const std::pair< FirstKeyType, SecondKeyType > &k)
 A utility function for pairs of key types. More...
double to_double (const Hilbert::HilbertIndices &bvt)

Function Documentation

◆ is_sorted()

template<typename KeyType >
bool libMesh::Parallel::Utils::is_sorted ( const std::vector< KeyType > &  v)
true if the vector v is sorted, false otherwise.

Requires O(N) comparisons, where N is the length of the vector. This was implemented because std::is_sorted() was an STL extension at the time.

Definition at line 51 of file parallel_conversion_utils.h.

52 {
53  if (v.empty())
54  return true;
56  for (std::size_t i=1; i<v.size(); i++)
57  if (v[i] < v[i-1])
58  return false;
60  return true;
61 }

◆ to_double() [1/3]

template<typename KeyType >
double libMesh::Parallel::Utils::to_double ( const KeyType &  k)

A utility function which converts whatever KeyType is to a double for the histogram bounds.

Definition at line 69 of file parallel_conversion_utils.h.

Referenced by to_double().

70 {
71  return static_cast<double>(k);
72 }

◆ to_double() [2/3]

template<typename FirstKeyType , typename SecondKeyType >
double libMesh::Parallel::Utils::to_double ( const std::pair< FirstKeyType, SecondKeyType > &  k)

A utility function for pairs of key types.

When finding bounds, the second entry of the pair is effectively "rounded away".

Definition at line 111 of file parallel_conversion_utils.h.

References to_double().

112 {
113  return to_double(k.first);
114 }
double to_double(const Hilbert::HilbertIndices &bvt)

◆ to_double() [3/3]

double libMesh::Parallel::Utils::to_double ( const Hilbert::HilbertIndices &  bvt)

Definition at line 121 of file parallel_conversion_utils.h.

122 {
123  return static_cast<double>(bvt.rack2);
124 }