Template Class SortedArrayDictionary

Class Documentation

template<std::totally_ordered K, class V>
class SortedArrayDictionary

a DICTIONARY realized with a vector sorted by key

Public Types

using Key = K

the type of the keys

using Value = V

the type of the values

using value_type = std::pair<K, V>
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = const std::pair<K, V>&
using const_reference = const std::pair<K, V>&
using const_iterator = const std::pair<K, V>*
using iterator = const_iterator

Public Functions

std::optional<V> lookup(const K &k) const

the value of the key k, or nothing, O( log n )

void insert(const K &k, const V &v)

associates the value v to the key k, O( n )

Post:

k has the value v

void remove(const K &k)

removes the key k, if it is there, O( n )

Post:

k is not there

bool empty(void) const
std::size_t size(void) const

the number of keys

const std::vector<std::pair<K, V>> &pairs(void) const

the pairs, sorted by key

inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const