54 named_subt::const_iterator it=s.find(name);
61 return it->second.id();
66 return get(name)==ID_1;
104 #if NAMED_SUB_IS_FORWARD_LIST
115 auto it = s.find(name);
132 #if NAMED_SUB_IS_FORWARD_LIST
133 return s.add(name, std::move(irep));
135 std::pair<named_subt::iterator, bool> entry = s.emplace(
136 std::piecewise_construct,
137 std::forward_as_tuple(name),
138 std::forward_as_tuple(irep));
141 entry.first->second = std::move(irep);
143 return entry.first->second;
147 #ifdef IREP_HASH_STATS
148 unsigned long long irep_cmp_cnt=0;
149 unsigned long long irep_cmp_ne_cnt=0;
154 #ifdef IREP_HASH_STATS
164 #ifdef IREP_HASH_STATS
174 named_subt::const_iterator this_it = this_named_sub.begin();
175 named_subt::const_iterator other_it = other_named_sub.begin();
177 while(this_it != this_named_sub.end() || other_it != other_named_sub.end())
179 if(this_it != this_named_sub.end() &&
is_comment(this_it->first))
185 if(other_it != other_named_sub.end() &&
is_comment(other_it->first))
192 this_it == this_named_sub.end() ||
193 other_it == other_named_sub.end() ||
194 this_it->first != other_it->first ||
195 this_it->second != other_it->second)
197 #ifdef IREP_HASH_STATS
224 if(i1_sub.size() != i2_sub.size())
230 if(i1_named_sub.size() != i2_named_sub.size())
233 for(std::size_t i=0; i<i1_sub.size(); i++)
234 if(!i1_sub[i].
full_eq(i2_sub[i]))
238 irept::named_subt::const_iterator i1_it=i1_named_sub.begin();
239 irept::named_subt::const_iterator i2_it=i2_named_sub.begin();
241 for(; i1_it!=i1_named_sub.end(); i1_it++, i2_it++)
242 if(i1_it->first!=i2_it->first ||
243 !i1_it->second.full_eq(i2_it->second))
261 if(X.sub.size()<Y.sub.size())
263 if(Y.sub.size()<X.sub.size())
267 irept::subt::const_iterator it1, it2;
269 for(it1=X.sub.begin(),
271 it1!=X.sub.end() && it2!=Y.sub.end();
281 INVARIANT(it1==X.sub.end() && it2==Y.sub.end(),
282 "Unequal lengths will return before this");
285 if(X.named_sub.size()<Y.named_sub.size())
287 if(Y.named_sub.size()<X.named_sub.size())
291 irept::named_subt::const_iterator it1, it2;
293 for(it1=X.named_sub.begin(),
294 it2=Y.named_sub.begin();
295 it1!=X.named_sub.end() && it2!=Y.named_sub.end();
299 if(it1->first<it2->first)
301 if(it2->first<it1->first)
304 if(
ordering(it1->second, it2->second))
306 if(
ordering(it2->second, it1->second))
310 INVARIANT(it1==X.named_sub.end() && it2==Y.named_sub.end(),
311 "Unequal lengths will return before this");
337 irept::subt::const_iterator it1, it2;
345 r=it1->compare(*it2);
351 "Unequal lengths will return before this");
363 irept::named_subt::const_iterator it1, it2;
390 it2 != i.
get_named_sub().end(),
"not at end of i.get_named_sub()");
392 r=it1->first.compare(it2->first);
396 r=it1->second.compare(it2->second);
406 "Unequal number of non-comments will return before this");
419 #ifdef IREP_HASH_STATS
420 unsigned long long irep_hash_cnt=0;
425 std::size_t result = 0;
427 for(
const auto &n : named_sub)
437 if(
read().hash_code!=0)
446 for(
const auto &irep : sub)
449 std::size_t number_of_named_ireps = 0;
451 for(
const auto &irep_entry : named_sub)
456 result =
hash_combine(result, irep_entry.second.hash());
457 number_of_named_ireps++;
461 result =
hash_finalize(result, sub.size() + number_of_named_ireps);
466 #ifdef IREP_HASH_STATS
479 for(
const auto &irep : sub)
483 for(
const auto &irep_entry : named_sub)
486 result =
hash_combine(result, irep_entry.second.full_hash());
489 const std::size_t named_sub_size = named_sub.size();
497 for(
unsigned i=0; i<indent; i++)
503 if(max_indent>0 && indent>max_indent)
523 result += irep_entry.second.pretty(indent + 2, max_indent);
528 for(
const auto &irep :
get_sub())
536 result += irep.pretty(indent + 2, max_indent);