54 named_subt::const_iterator it=s.find(name);
61 return it->second.id();
66 return get(name)==ID_1;
95 #ifdef NAMED_SUB_IS_FORWARD_LIST
106 auto it = s.find(name);
123 #ifdef NAMED_SUB_IS_FORWARD_LIST
124 return s.add(name, std::move(irep));
126 std::pair<named_subt::iterator, bool> entry = s.emplace(
127 std::piecewise_construct,
128 std::forward_as_tuple(name),
129 std::forward_as_tuple(irep));
132 entry.first->second = std::move(irep);
134 return entry.first->second;
138 #ifdef IREP_HASH_STATS
139 unsigned long long irep_cmp_cnt=0;
140 unsigned long long irep_cmp_ne_cnt=0;
145 #ifdef IREP_HASH_STATS
155 #ifdef IREP_HASH_STATS
165 named_subt::const_iterator this_it = this_named_sub.begin();
166 named_subt::const_iterator other_it = other_named_sub.begin();
168 while(this_it != this_named_sub.end() || other_it != other_named_sub.end())
170 if(this_it != this_named_sub.end() &&
is_comment(this_it->first))
176 if(other_it != other_named_sub.end() &&
is_comment(other_it->first))
183 this_it == this_named_sub.end() ||
184 other_it == other_named_sub.end() ||
185 this_it->first != other_it->first ||
186 this_it->second != other_it->second)
188 #ifdef IREP_HASH_STATS
215 if(i1_sub.size() != i2_sub.size())
221 if(i1_named_sub.size() != i2_named_sub.size())
224 for(std::size_t i=0; i<i1_sub.size(); i++)
225 if(!i1_sub[i].
full_eq(i2_sub[i]))
229 irept::named_subt::const_iterator i1_it=i1_named_sub.begin();
230 irept::named_subt::const_iterator i2_it=i2_named_sub.begin();
232 for(; i1_it!=i1_named_sub.end(); i1_it++, i2_it++)
233 if(i1_it->first!=i2_it->first ||
234 !i1_it->second.full_eq(i2_it->second))
252 if(X.sub.size()<Y.sub.size())
254 if(Y.sub.size()<X.sub.size())
258 irept::subt::const_iterator it1, it2;
260 for(it1=X.sub.begin(),
262 it1!=X.sub.end() && it2!=Y.sub.end();
272 INVARIANT(it1==X.sub.end() && it2==Y.sub.end(),
273 "Unequal lengths will return before this");
276 if(X.named_sub.size()<Y.named_sub.size())
278 if(Y.named_sub.size()<X.named_sub.size())
282 irept::named_subt::const_iterator it1, it2;
284 for(it1=X.named_sub.begin(),
285 it2=Y.named_sub.begin();
286 it1!=X.named_sub.end() && it2!=Y.named_sub.end();
290 if(it1->first<it2->first)
292 if(it2->first<it1->first)
295 if(
ordering(it1->second, it2->second))
297 if(
ordering(it2->second, it1->second))
301 INVARIANT(it1==X.named_sub.end() && it2==Y.named_sub.end(),
302 "Unequal lengths will return before this");
328 irept::subt::const_iterator it1, it2;
336 r=it1->compare(*it2);
342 "Unequal lengths will return before this");
354 irept::named_subt::const_iterator it1, it2;
381 it2 != i.
get_named_sub().end(),
"not at end of i.get_named_sub()");
383 r=it1->first.compare(it2->first);
387 r=it1->second.compare(it2->second);
397 "Unequal number of non-comments will return before this");
410 #ifdef IREP_HASH_STATS
411 unsigned long long irep_hash_cnt=0;
416 std::size_t result = 0;
418 for(
const auto &n : named_sub)
428 if(
read().hash_code!=0)
439 std::size_t number_of_named_ireps = 0;
446 number_of_named_ireps++;
449 result =
hash_finalize(result, sub.size() + number_of_named_ireps);
454 #ifdef IREP_HASH_STATS
476 const std::size_t named_sub_size = named_sub.size();
484 for(
unsigned i=0; i<indent; i++)
490 if(max_indent>0 && indent>max_indent)
510 result+=it->second.pretty(indent+2, max_indent);
523 result+=it->pretty(indent+2, max_indent);