20#ifndef LIBMESH_VECTORMAP_H
21#define LIBMESH_VECTORMAP_H
28#include "libmesh/libmesh_common.h"
60template <
typename Key,
typename Tp>
61class 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)
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
std::pair< Key, Tp > value_type
const Tp & operator[](const key_type &key) const
void insert(const value_type &x)
Inserts x into the vectormap.
difference_type count(const key_type &key) const
vector_type::const_iterator const_iterator
const_iterator find(const key_type &key) const
void emplace(Args &&... args)
Inserts x into the vector map, using "args" to construct it in-place.
void sort()
Sort & unique the vectormap, preparing for use.
std::vector< value_type > vector_type
vectormap()
Default constructor.
iterator find(const key_type &key)
vector_type::iterator iterator
vectormap(const vectormap< Key, Tp > &other)
Copy constructor.
vector_type::difference_type difference_type
The libMesh namespace provides an interface to certain functionality in the library.
Equality comparison, based solely on first element in a pair.
bool operator()(const value_type &lhs, const value_type &rhs) const
Strict weak ordering, based solely on first element in a pair.
bool operator()(const value_type &lhs, const value_type &rhs) const