11 m_dict.insert_or_assign(key, value);
16 if (
const auto it =
m_dict.find(key); it !=
m_dict.end())
23 return m_dict.contains(key);
33 std::vector<Value>
keys;
35 std::ranges::copy(std::ranges::views::keys(
m_dict), std::back_inserter(
keys));
47 std::string out =
"{";
50 for (
const auto& [key, value] :
m_dict)
52 out += key.toString(vm) +
": " + value.toString(vm);
54 if (i + 1 !=
m_dict.size())
Define how dictionaries are handled.
The ArkScript virtual machine, executing ArkScript bytecode.
ankerl::unordered_dense::map< Value, Value > m_dict
std::vector< Value > keys()
Get a list of the dict keys.
std::string toString(VM &vm) const
Convert the dictionary to a string for pretty printing.
bool contains(const Value &key) const
Check that a key exists.
void set(const Value &key, const Value &value)
Assign a key to a value inside the dict.
void remove(const Value &key)
Remove an entry from the dict via its key.
std::size_t size() const
Compute the number of (key, value) pairs in the dict.
const Value & get(const Value &key)
Try to get a value from a given key. If no value is found, return Nil.
const auto Nil
ArkScript Nil value.