20 #ifndef LIBMESH_VECTORMAP_H 21 #define LIBMESH_VECTORMAP_H 28 #include "libmesh/libmesh_common.h" 60 template <
typename Key,
typename Tp>
61 class vectormap :
public std::vector<std::pair<Key, Tp>>
71 typedef typename vector_type::iterator
iterator;
83 {
return lhs.first < rhs.first; }
93 {
return lhs.first == rhs.first; }
109 std::vector<
std::pair<Key, Tp>> (other),
126 template<
class... Args>
130 this->emplace_back(args...);
138 std::sort (this->begin(), this->end(),
FirstOrder());
140 this->erase (std::unique (this->begin(), this->end(),
FirstCompare()), this->end());
160 libmesh_error_msg_if(lower_bound == this->end() || lower_bound->first != key,
161 "Error in vectormap::operator[], key not found. " 162 "If you are searching for values you aren't sure exist, try vectormap::find() instead.");
164 return lower_bound->second;
184 if (lb == this->end() || lb->first != key)
209 if (lb == this->end() || lb->first != key)
234 if (lb == this->end() || lb->first != key)
248 #endif // LIBMESH_VECTORMAP_H iterator find(const key_type &key)
std::vector< value_type > vector_type
std::pair< Key, Tp > value_type
vector_type::const_iterator const_iterator
The libMesh namespace provides an interface to certain functionality in the library.
Strict weak ordering, based solely on first element in a pair.
vectormap()
Default constructor.
void sort()
Sort & unique the vectormap, preparing for use.
void insert(const value_type &x)
Inserts x into the vectormap.
vectormap(const vectormap< Key, Tp > &other)
Copy constructor.
difference_type count(const key_type &key) const
bool operator()(const value_type &lhs, const value_type &rhs) const
const_iterator find(const key_type &key) const
bool operator()(const value_type &lhs, const value_type &rhs) const
vector_type::difference_type difference_type
vector_type::iterator iterator
Equality comparison, based solely on first element in a pair.
void emplace(Args &&... args)
Inserts x into the vector map, using "args" to construct it in-place.
This vectormap templated class is intended to provide the performance characteristics of a sorted s...
const Tp & operator[](const key_type &key) const