Value iteration

This commit is contained in:
Michael Davidsaver
2020-01-27 17:52:56 -08:00
parent d4f4fe970d
commit c78ec7718b
3 changed files with 180 additions and 4 deletions
+47
View File
@@ -643,6 +643,53 @@ const Value Value::operator[](const char *name) const
return ret;
}
void Value::_iter_fl(Value::IterInfo &info, bool first) const
{
if(!store)
throw NoField();
if(info.depth) {
info.pos = info.nextcheck = store->index() + (first ? 1u : desc->size());
if(info.marked)
_iter_advance(info);
} else {
info.pos = info.nextcheck = first ? 0u : desc->miter.size();
}
}
void Value::_iter_advance(IterInfo& info) const
{
assert(info.depth);
// scan forward to find next non-marked
for(auto idx : range(info.pos, desc->size())) {
auto S = store.get() + idx;
if(S->valid) {
auto D = desc + idx;
info.pos = idx;
info.nextcheck = idx + D->size();
return;
}
}
info.pos = info.nextcheck = desc->size();
}
Value Value::_iter_deref(const IterInfo& info) const
{
auto idx = info.pos;
if(!info.depth)
idx = desc->miter[idx].second;
decltype (store) store2(store, store.get()+idx);
Value ret;
ret.store = std::move(store2);
ret.desc = desc + idx;
return ret;
}
static
void show_Value(std::ostream& strm,
const std::string& member,