30 typedef MAP<const KEY *, const VALUE *, COMP, ALLOC> map_t;
34 typedef typename map_t::value_type value_type;
35 typedef typename map_t::iterator iterator;
36 typedef typename map_t::const_iterator const_iterator;
37 typedef typename map_t::reverse_iterator reverse_iterator;
38 typedef typename map_t::const_reverse_iterator const_reverse_iterator;
44 elem_ref(
NodeMap &s,
const KEY *k) : self(s), key(k) {}
45 const VALUE *operator=(
const VALUE *v)
const {
return self.symbols[key] = v; }
46 operator const VALUE *()
const {
return self.symbols.at(key); }
50 const_iterator begin()
const {
return symbols.begin(); }
51 const_iterator end()
const {
return symbols.end(); }
52 iterator begin() {
return symbols.begin(); }
53 iterator end() {
return symbols.end(); }
54 const_reverse_iterator rbegin()
const {
return symbols.rbegin(); }
55 const_reverse_iterator rend()
const {
return symbols.rend(); }
56 reverse_iterator rbegin() {
return symbols.rbegin(); }
57 reverse_iterator rend() {
return symbols.rend(); }
58 size_t count(
cstring name)
const {
return symbols.count(name); }
59 size_t size()
const {
return symbols.size(); }
60 bool empty()
const {
return symbols.empty(); }
61 size_t erase(
const KEY *k) {
return symbols.erase(k); }
62 iterator erase(const_iterator p) {
return symbols.erase(p); }
63 iterator erase(const_iterator f, const_iterator l) {
return symbols.erase(f, l); }
64 const_iterator find(
const KEY *k)
const {
return symbols.find(k); }
66 const U *get(
const KEY *k)
const {
67 for (
auto it = symbols.find(k); it != symbols.end() && it->first == k; it++)
68 if (
auto rv = it->second->template
to<U>())
return rv;
71 elem_ref operator[](
const KEY *k) {
return elem_ref(*
this, k); }
72 const VALUE *operator[](
const KEY *k)
const {
return symbols.at(k); }
73 const VALUE *&at(
const KEY *k) {
return symbols.at(k); }
74 const VALUE *
const &at(
const KEY *k)
const {
return symbols.at(k); }
76 bool operator==(
const Node &a)
const override {
return a == *
this; }
77 bool operator==(
const NodeMap &a)
const {
return symbols == a.symbols; }
78 bool equiv(
const Node &a_)
const override {
79 if (
static_cast<const Node *
>(
this) == &a_)
return true;
82 if (size() != a.size())
return false;
84 for (
auto &el : *
this)
85 if (el.first != it->first || !el.second->equiv(*(it++)->second))
return false;
88 cstring node_type_name()
const override {
89 return "NodeMap<" + KEY::static_type_name() +
"," + VALUE::static_type_name() +
">";
91 static cstring static_type_name() {
92 return "NodeMap<" + KEY::static_type_name() +
"," + VALUE::static_type_name() +
">";
94 void visit_children(
Visitor &v)
override;
95 void visit_children(
Visitor &v)
const override;