11/*
2- * Copyright (C) 2019-2021 HERE Europe B.V.
2+ * Copyright (C) 2019-2025 HERE Europe B.V.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -47,20 +47,21 @@ struct CacheCost {
4747 * @brief A generic key-value LRU cache.
4848 *
4949 * This cache stores elements in a map up to the specified maximum size.
50- * The cache eviction follows the LRU principle: the element that was accessed last
51- * is evicted last.
50+ * The cache eviction follows the LRU principle: the element that was accessed
51+ * last is evicted last.
5252 *
5353 * The specializations return a non-zero value for any given object.
54- *
54+ *
5555 * @tparam Key The `LruCache` key type.
5656 * @tparam Value The `LruCache` value type.
5757 * @tparam CacheCostFunc The cache cost functor.
5858 * The specializations should return a non-zero value for any given object.
5959 * The default implementation returns "1" as the size for each object.
6060 * @tparam Compare The comparison function to be used for sorting keys.
61- * The default value of `std::less` is used, which sorts the keys in ascending order.
61+ * The default value of `std::less` is used, which sorts the keys in ascending
62+ * order.
6263 * @tparam Alloc The allocator to be used for allocating internal data.
63- * The default value of `std::allocator` is used.
64+ * The default value of `std::allocator` is used.
6465 */
6566template <typename Key, typename Value,
6667 typename CacheCostFunc = CacheCost<Value>,
@@ -88,16 +89,16 @@ class LruCache {
8889 */
8990 class ValueType {
9091 public:
91- /* *
92- * @brief Gets the key of the `ValueType` object.
93- *
94- * @return The key of the `ValueType` object.
95- */
92+ /* *
93+ * @brief Gets the key of the `ValueType` object.
94+ *
95+ * @return The key of the `ValueType` object.
96+ */
9697 inline const Key& key () const ;
9798
9899 /* *
99100 * @brief Gets the value of the `ValueType` object.
100- *
101+ *
101102 * @return The value of the `ValueType` object.
102103 */
103104 inline const Value& value () const ;
@@ -121,21 +122,21 @@ class LruCache {
121122 // / A typedef for the `ValueType` constant pointer.
122123 typedef const value_type* pointer;
123124
124- // /Creates a constant iterator object.
125+ // / Creates a constant iterator object.
125126 const_iterator () = default ;
126- // /Creates a constant iterator object.
127+ // / Creates a constant iterator object.
127128 const_iterator (const const_iterator&) = default ;
128129 /* *
129130 * @brief Copies this and the specified iterator to this.
130- *
131+ *
131132 * @return A refenrence to this object.
132133 */
133134 const_iterator& operator =(const const_iterator&) = default ;
134135
135136 /* *
136137 * @brief Checks whether the values of the `const_iterator`
137138 * parameter are the same as the values of the `other` parameter.
138- *
139+ *
139140 * @param other The `const_iterator` instance.
140141 *
141142 * @return True if the values are the same; false otherwise.
@@ -144,9 +145,9 @@ class LruCache {
144145 /* *
145146 * @brief Checks whether the values of the `const_iterator`
146147 * parameter are not the same as the values of the `other` parameter.
147- *
148+ *
148149 * @param other The `const_iterator` instance.
149- *
150+ *
150151 * @return True if the values are not the same; false otherwise.
151152 */
152153 inline bool operator !=(const const_iterator& other) const {
@@ -155,40 +156,42 @@ class LruCache {
155156
156157 /* *
157158 * @brief Iterates to the next `LruCache` object.
158- *
159+ *
159160 * @return A reference to this.
160161 */
161162 inline const_iterator& operator ++();
162163 /* *
163- * @brief Iterates the specified number of times to the next `LruCache` object.
164- *
164+ * @brief Iterates the specified number of times to the next `LruCache`
165+ * object.
166+ *
165167 * @return A new constant iterator.
166168 */
167169 inline const_iterator operator ++(int );
168170
169171 /* *
170172 * @brief Iterates to the previous `LruCache` object.
171- *
173+ *
172174 * @return A reference to this.
173175 */
174176 inline const_iterator& operator --();
175177 /* *
176- * @brief Iterates the specified number of times to the previous `LruCache` object.
177- *
178+ * @brief Iterates the specified number of times to the previous `LruCache`
179+ * object.
180+ *
178181 * @return A new constant iterator.
179182 */
180183 inline const_iterator operator --(int );
181184
182185 /* *
183186 * @brief Gets a reference to this object.
184- *
187+ *
185188 * @return The reference to this.
186189 */
187190 reference operator *() const { return *this ; }
188191
189192 /* *
190193 * @brief Gets a pointer to this object.
191- *
194+ *
192195 * @return The pointer to this.
193196 */
194197 pointer operator ->() const { return this ; }
@@ -277,29 +280,32 @@ class LruCache {
277280 * @brief Inserts a key-value pair in the cache.
278281 *
279282 * @note If the key already exists in the cache, it is promoted in the
280- * LRU, but its value and cost are not updated. To update or insert existing values,
281- * use `InsertOrAssign` instead.
283+ * LRU, but its value and cost are not updated. To update or insert existing
284+ * values, use `InsertOrAssign` instead.
282285 *
283286 * If the key or value is an rvalue reference, they are moved;
284287 * copied otherwise.
285288 *
286- * @note This function behaves analogously to `std::map`. Even if the insertion
287- * fails, the key and value can be moved. Do not access them further.
289+ * @note This function behaves analogously to `std::map`. Even if the
290+ * insertion fails, the key and value can be moved. Do not access them
291+ * further.
288292 *
289293 * @param key The key to add.
290294 * @param value The value to add.
291295 *
292- * @return A pair of bool and an iterator, analogously to `std::map::insert()`.
293- * If the bool is true, the item is inserted, and the iterator points
294- * to the newly inserted item. If the bool is false and the iterator points to
295- * `end()`, the item cannot be inserted. Otherwise, the bool is false, and
296- * the iterator points to the item that prevented the insertion.
296+ * @return A pair of bool and an iterator, analogously to
297+ * `std::map::insert()`. If the bool is true, the item is inserted, and the
298+ * iterator points to the newly inserted item. If the bool is false and the
299+ * iterator points to `end()`, the item cannot be inserted. Otherwise, the
300+ * bool is false, and the iterator points to the item that prevented the
301+ * insertion.
297302 */
298303 template <typename _Key, typename _Value>
299304 std::pair<const_iterator, bool > Insert (_Key&& key, _Value&& value);
300305
301306 /* *
302- * @brief Inserts a key-value pair in the cache or updates an existing key-value pair.
307+ * @brief Inserts a key-value pair in the cache or updates an existing
308+ * key-value pair.
303309 *
304310 * @note If the key already exists in the cache, its value and cost are
305311 * updated. Not to update the existing key-value pair, use `Insert` instead.
@@ -335,7 +341,7 @@ class LruCache {
335341
336342 /* *
337343 * @brief Removes a key from the cache.
338- *
344+ *
339345 * @param it The iterator of the key that should be removed.
340346 *
341347 * @return A new iterator.
@@ -748,7 +754,7 @@ inline typename LruCache<Key, Value, CacheCostFunc, Compare,
748754 Alloc>::const_iterator&
749755LruCache<Key, Value, CacheCostFunc, Compare, Alloc>::const_iterator::
750756operator --() {
751- this ->m_it = this ->m_it ->second .m_previous ;
757+ this ->m_it = this ->m_it ->second .previous_ ;
752758 return *this ;
753759}
754760
@@ -759,7 +765,7 @@ inline
759765 LruCache<Key, Value, CacheCostFunc, Compare, Alloc>::const_iterator::
760766 operator --(int ) {
761767 typename MapType::const_iterator old_value = this ->m_it ;
762- this ->m_it = this ->m_it ->second .m_previous ;
768+ this ->m_it = this ->m_it ->second .previous_ ;
763769 return const_iterator{old_value};
764770}
765771
0 commit comments