9 #ifndef CPROVER_UTIL_FORWARD_LIST_AS_MAP_H
10 #define CPROVER_UTIL_FORWARD_LIST_AS_MAP_H
13 #include <forward_list>
19 template <
typename keyt,
typename mappedt>
26 using iterator =
typename implementationt::iterator;
41 if(it != this->end() && it->first == name)
43 iterator before = this->before_begin();
44 while(std::next(before) != it)
46 this->erase_after(before);
54 if(it == this->end() || it->first != name)
64 if(it == this->end() || it->first != name)
66 iterator before = this->before_begin();
67 while(std::next(before) != it)
69 it = this->emplace_after(before, name, mappedt());
77 return add(name)->second;
80 mappedt &
add(
const keyt &name, mappedt irep)
84 if(it == this->end() || it->first != name)
86 iterator before = this->before_begin();
87 while(std::next(before) != it)
89 it = this->emplace_after(before, name, std::move(irep));
92 it->second = std::move(irep);
99 return narrow<std::size_t>(std::distance(this->begin(), this->end()));
103 static bool order(
const std::pair<keyt, mappedt> &a,
const keyt &b)
110 return std::lower_bound(this->begin(), this->end(),
id,
order);
115 return std::lower_bound(this->begin(), this->end(),
id,
order);
119 #endif // CPROVER_UTIL_FORWARD_LIST_AS_MAP_H