x-procedure2: + dict_lookup() primitive

This commit is contained in:
Roland Conybeare 2026-03-16 00:57:17 -05:00
commit bd811111a1
2 changed files with 19 additions and 0 deletions

View file

@ -35,6 +35,21 @@ namespace xo {
return new (mem) DDictionary(keys, values);
}
std::optional<obj<AGCObject>>
DDictionary::lookup(const DString * key) const noexcept
{
for (DArray::size_type i = 0, z = keys_->size(); i < z; ++i) {
auto i_key = obj<AGCObject,DString>::from(keys_->at(i));
assert(i_key);
if (DString::compare(*key, *i_key.data()) == 0)
return values_->at(i);
}
return {};
}
std::pair<const DString *, obj<AGCObject>>
DDictionary::at_index(size_type ix) const
{