3#ifndef DUNE_MMESH_GRID_MULTIID_HH
4#define DUNE_MMESH_GRID_MULTIID_HH
17 using ThisType = MultiId;
18 using T = std::size_t;
19 using VT = std::vector<T>;
22 using Storage = std::array<T, 4>;
24 MultiId() : size_(0), hash_(-1) {}
26 MultiId(
const MultiId& other)
27 : vt_(other.vt_), size_(other.size_), hash_(other.hash_) {}
29 MultiId(
const std::vector<T>& vt) : size_(vt.size()), hash_(-1) {
31 for (
const auto& v : vt) vt_[i++] = v;
34 MultiId(std::initializer_list<T> l) : MultiId(
std::vector<T>(l)) {}
36 MultiId(T t) : MultiId({t}) {}
38 ThisType& operator=(
const ThisType& b) {
47 bool operator<(
const ThisType& b)
const {
48 if (size() != b.size())
return size() < b.size();
50 for (
int i = 0; i < size_; ++i)
51 if (vt_[i] != b.vt_[i])
return vt_[i] < b.vt_[i];
56 bool operator==(
const ThisType& b)
const {
57 if (size() != b.size())
return false;
59 for (
int i = 0; i < size_; ++i)
60 if (vt_[i] != b.vt_[i])
return false;
65 bool operator<=(
const ThisType& b)
const {
return !b.operator<(*this); }
67 bool operator!=(
const ThisType& b)
const {
return !operator==(b); }
69 std::size_t size()
const {
return size_; }
74 for (
int i = 0; i < size_; ++i) vec.push_back(vt_[i]);
79 std::size_t hash()
const {
80 if (hash_ == std::size_t(-1)) {
86 static constexpr std::hash<std::size_t> hasher;
87 hash_ = hasher(vt_[0]);
88 for (std::size_t i = 1; i < size_; ++i)
89 hash_ = hash_ ^ (hasher(vt_[i]) << i);
97 mutable std::size_t hash_;
106struct hash<Dune::MMeshImpl::MultiId> {
107 size_t operator()(
const Dune::MMeshImpl::MultiId&
id)
const {
114 const Dune::MMeshImpl::MultiId& multiId) {
115 for (
const auto& v : multiId.vt()) os << v <<
" ";
Some common helper methods.
ostream & operator<<(ostream &os, const Dune::MMeshImpl::MultiId &multiId)
overload operator<<
Definition: multiid.hh:113