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

@ -110,6 +110,9 @@ namespace xo {
/** current dictionary size (number of key-value pairs) **/
size_type size() const noexcept { return keys_->size(); }
/** return value associated with @p key, if key is present **/
std::optional<obj<AGCObject>> lookup(const DString * key) const noexcept;
/** return element @p key-value pair at position @p index (0-based) **/
std::pair<const DString *, obj<AGCObject>> at_index(size_type index) const;
/** return @p i'th key. O(1) **/
@ -117,6 +120,7 @@ namespace xo {
/** return @p i'th value. O(1) **/
obj<AGCObject> value_at_index(size_type i) const;
auto operator[](const DString * key) const noexcept { return LValue<decltype(this)>(this, key); }
auto operator[](const DString * key) noexcept { return LValue<decltype(this)>(this, key); }