ArkScript
A small, lisp-inspired, functional scripting language
Ark::internal::Dict Class Reference

#include <Dict.hpp>

Public Member Functions

 Dict ()=default
 
void set (const Value &key, const Value &value)
 Assign a key to a value inside the dict.
 
const Valueget (const Value &key)
 Try to get a value from a given key. If no value is found, return Nil.
 
bool contains (const Value &key) const
 Check that a key exists.
 
void remove (const Value &key)
 Remove an entry from the dict via its key.
 
std::vector< Valuekeys ()
 Get a list of the dict keys.
 
std::size_t size () const
 Compute the number of (key, value) pairs in the dict.
 
std::string toString (VM &vm) const
 Convert the dictionary to a string for pretty printing.
 

Private Attributes

ankerl::unordered_dense::map< Value, Valuem_dict
 

Friends

bool operator== (const Dict &A, const Dict &B)
 

Detailed Description

Definition at line 28 of file Dict.hpp.

Constructor & Destructor Documentation

◆ Dict()

Ark::internal::Dict::Dict ( )
default

Member Function Documentation

◆ contains()

bool Ark::internal::Dict::contains ( const Value & key) const
nodiscard

Check that a key exists.

Parameters
key
Returns
true if the dict has the key
false otherwise

Definition at line 21 of file Dict.cpp.

References m_dict.

◆ get()

const Value & Ark::internal::Dict::get ( const Value & key)

Try to get a value from a given key. If no value is found, return Nil.

Parameters
key
Returns
const Value&

Definition at line 14 of file Dict.cpp.

References m_dict, and Ark::Nil.

◆ keys()

std::vector< Value > Ark::internal::Dict::keys ( )

Get a list of the dict keys.

Returns
std::vector<Value>

Definition at line 31 of file Dict.cpp.

References keys(), and m_dict.

Referenced by keys().

◆ remove()

void Ark::internal::Dict::remove ( const Value & key)

Remove an entry from the dict via its key.

Parameters
key

Definition at line 26 of file Dict.cpp.

References m_dict.

◆ set()

void Ark::internal::Dict::set ( const Value & key,
const Value & value )

Assign a key to a value inside the dict.

Parameters
key
value

Definition at line 9 of file Dict.cpp.

References m_dict.

◆ size()

std::size_t Ark::internal::Dict::size ( ) const
nodiscard

Compute the number of (key, value) pairs in the dict.

Returns
std::size_t

Definition at line 40 of file Dict.cpp.

References m_dict.

◆ toString()

std::string Ark::internal::Dict::toString ( VM & vm) const

Convert the dictionary to a string for pretty printing.

Parameters
vm
Returns
std::string

Definition at line 45 of file Dict.cpp.

References m_dict.

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const Dict & A,
const Dict & B )
friend

Definition at line 93 of file Dict.hpp.

Member Data Documentation

◆ m_dict

ankerl::unordered_dense::map<Value, Value> Ark::internal::Dict::m_dict
private

Definition at line 90 of file Dict.hpp.

Referenced by contains(), get(), keys(), remove(), set(), size(), and toString().


The documentation for this class was generated from the following files: