Skip to content

a222red/Dictionary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Dictionary

A recreation of Python's dict class in C++

Usage

The classes dict and pair are templates:

template<key_type, val_type>
class dict;
template<key_type, val_type>
class pair;

Usage is similar to Python:

dict<string,string> d;
d["foo"] = "bar";

Methods

val_type pop(key_type key)

Remove an item from from the dict and return its value


std::vector<pair<key_type, val_type>> items()

Return a vector containing every key-value pair in the dict


void clear()

Remove all key-value pairs in the dict


pair<key_type, val_type> pop_item()

Remove the most recently added key-value pair andd return it as a vector


std::vector<key_type> list_keys()

Return a vector containing all keys in the dict


std::vector<val_type> list_values()

Return a vector containing all values in the dict


key_type& get_key_by_value(val_type val)

Return a reference to a key by its value


key_type& index_key(int i)

Return a reference to a key by its index


val_type& index_value(int i)

Return a reference to a value by its index


int len()

Return the amount of items in the dict

About

A recreation of Python's dict class in C++

Resources

License

Stars

Watchers

Forks

Languages