32#ifndef __ADS_SortedArrayDictionary
33 #define __ADS_SortedArrayDictionary
60template< std::totally_ordered K ,
class V >
89 [[nodiscard]] std::optional< V >
lookup(
const K & k )
const;
109 void insert(
const K & k ,
const V & v );
121 [[nodiscard]] std::optional< std::pair< K , V > >
127 [[nodiscard]]
const K *
findKey(
const K & k )
const;
135 [[nodiscard]]
bool empty(
void )
const;
138 [[nodiscard]] std::size_t
size(
void )
const;
141 [[nodiscard]]
const std::vector< std::pair< K , V > > &
pairs(
void )
const;
166 return( f_A.data() + f_A.size() );
176 [[nodiscard]] std::size_t place(
const K & k )
const;
179 [[nodiscard]]
bool sorted(
void )
const;
181 std::vector< std::pair< K , V > > f_A;
193#include "ADS/dictionary/impl/SortedArrayDictionary.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a DICTIONARY realized with a vector sorted by key
Definition SortedArrayDictionary.h:62
K Key
the type of the keys
Definition SortedArrayDictionary.h:66
const_iterator cbegin(void) const
the constant iterator on the first item
Definition SortedArrayDictionary.h:169
const std::pair< K, V > & reference
a reference to an item
Definition SortedArrayDictionary.h:154
const std::pair< K, V > * const_iterator
the iterator on the items, constant
Definition SortedArrayDictionary.h:158
const std::pair< K, V > & const_reference
a constant reference to an item
Definition SortedArrayDictionary.h:156
const K * findKey(const K &k) const
the address of the key , nil if absent, in time: the find( x ) of a USet of Morin [see DictionarySet...
const K * lowerBoundKey(const K &k) const
the address of the smallest key not smaller than , nil if none, in time: the find( x ) of an SSet of...
V Value
the type of the values
Definition SortedArrayDictionary.h:67
std::ptrdiff_t difference_type
the type of the distances between two iterators
Definition SortedArrayDictionary.h:152
void insert(const K &k, const V &v)
associates the value to the key ,
const_iterator end(void) const
the iterator past the last item
Definition SortedArrayDictionary.h:165
bool contains(const K &k) const
true if the key is there, by the binary search of lookup()
const_iterator iterator
the iterator on the items
Definition SortedArrayDictionary.h:160
const std::vector< std::pair< K, V > > & pairs(void) const
the pairs, sorted by key
bool empty(void) const
true if there are no keys
std::size_t size(void) const
the number of keys
std::pair< K, V > value_type
the type of the items, for the standard library
Definition SortedArrayDictionary.h:148
void remove(const K &k)
removes the key , if it is there, moving the pairs after it one place back,
const_iterator begin(void) const
the iterator on the first item
Definition SortedArrayDictionary.h:163
std::size_t size_type
the type of the sizes
Definition SortedArrayDictionary.h:150
const_iterator cend(void) const
the constant iterator past the last item
Definition SortedArrayDictionary.h:171
std::optional< std::pair< K, V > > lowerBound(const K &k) const
the smallest key not smaller than and its value, or nothing (the find( x ) of an SSet of Morin),...
std::optional< V > lookup(const K &k) const
the value of the key , or nothing,