template<typename T>
py::Lict class

Dict-like data structure by std::vector and Range.

The Lict class is a custom implementation of an unordered mapping with integer keys and generic values, which adapts a vector to behave like a dictionary.

Public types

using key_type = size_t
using value_type = T
using iterator = py::Range<key_type>::iterator
using const_iterator = py::Range<key_type>::iterator

Constructors, destructors, conversion operators

Lict(std::vector<T> lst) explicit
Constructor for a dictionary-like adaptor for a vector.

Public functions

auto operator[](const key_type& key) const -> const T&
This function allows you to access an element in a Lict object by its index.
auto operator[](const key_type& key) -> T&
This function sets the value at a given index in a list-like object.
auto at(const key_type& key) const -> const T&
This function allows you to access an element in a Lict object by its index.
auto begin() const -> iterator
auto end() const -> iterator
auto contains(const key_type& key) const -> bool
The contains function checks if a given value is present in the rng attribute of the object.
auto size() const -> size_t
This function returns the length of the rng attribute of the object.
auto values() const -> const auto&
The values function returns an iterator that yields the elements of the lst attribute of the Lict object.
auto values() -> auto&
The values function returns an iterator that yields the elements of the lst attribute of the Lict object.
auto items() -> auto
The function returns an enumeration of the items in the list.

Function documentation

template<typename T _1>
py::Lict<_1>::Lict(std::vector<T> lst) explicit

Constructor for a dictionary-like adaptor for a vector.

Parameters
lst in The lst parameter is a vector. It is used to initialize the self.lst attribute of the class

template<typename T _1>
const T& py::Lict<_1>::operator[](const key_type& key) const

This function allows you to access an element in a Lict object by its index.

Parameters
key in The key parameter is of type size_t and it represents the index of the element that you want to retrieve from the list
Returns the item at the specified index in the lst attribute.

Examples:

auto a = Lict({1, 4, 3, 6}); a[2] 3

template<typename T _1>
T& py::Lict<_1>::operator[](const key_type& key)

This function sets the value at a given index in a list-like object.

Parameters
key in The key parameter represents the index at which the new value should be set in the list

Examples:

auto a = Lict({1, 4, 3, 6}); a[2] = 7 a[2] 7

template<typename T _1>
const T& py::Lict<_1>::at(const key_type& key) const

This function allows you to access an element in a Lict object by its index.

Parameters
key in The key parameter is of type size_t and it represents the index of the element that you want to retrieve from the list
Returns the item at the specified index in the lst attribute.

Examples:

auto a = Lict({1, 4, 3, 6}); a.at(2) 3

template<typename T _1>
iterator py::Lict<_1>::begin() const

Returns iterator

template<typename T _1>
iterator py::Lict<_1>::end() const

Returns iterator

template<typename T _1>
bool py::Lict<_1>::contains(const key_type& key) const

The contains function checks if a given value is present in the rng attribute of the object.

Parameters
key in The key parameter represents the value that we want to check if it is present in the self.rng attribute
Returns The method is returning a boolean value, indicating whether the given value is present in the self.rng attribute.

Examples:

auto a = Lict({1, 4, 3, 6}); a.contains(2) true

template<typename T _1>
size_t py::Lict<_1>::size() const

This function returns the length of the rng attribute of the object.

Returns The size function is returning the size of the self.rng attribute.

Examples:

auto a = Lict({1, 4, 3, 6}); a.size() 4

template<typename T _1>
const auto& py::Lict<_1>::values() const

The values function returns an iterator that yields the elements of the lst attribute of the Lict object.

Returns The values method returns a const reference to the vector object.

Examples:

const auto a = Lict({1, 4, 3, 6}); for (const auto &i : a.values()) { ... fmt::print(i); ... } 1 4 3 6

template<typename T _1>
auto& py::Lict<_1>::values()

The values function returns an iterator that yields the elements of the lst attribute of the Lict object.

Returns The values method returns a reference to the vector object.

Examples:

auto a = Lict({1, 4, 3, 6}); for (auto& i : a.values()) { ... i += 1; ... fmt::print(i); ... } 2 5 4 7

template<typename T _1>
auto py::Lict<_1>::items()

The function returns an enumeration of the items in the list.

Returns : The items method is returning an enumeration of the lst attribute.

Examples:

auto a = Lict({1, 4, 3, 6}); for (auto& [key, value] : a.items()) { ... fmt::print(key, value); ... } (0, 1) (1, 4) (2, 3) (3, 6)