Apollo
6.0
Open source self driving car software
|
The data structure of the LRUCache. More...
#include <base_map_cache.h>
Public Types | |
using | DestroyFunc = std::function< bool(Element *)> |
Public Member Functions | |
MapNodeCache (unsigned int capacity, const DestroyFunc &destroy_func) | |
The constructor. More... | |
~MapNodeCache () | |
The destructor. More... | |
bool | Get (const Key &key, Element **value) |
Find element for key if it exists in the cache. If not exist, return false. More... | |
bool | GetSilent (const Key &key, Element **value) |
Find element for key if it exists in the cache. If not exist, return false. This function is thread safe, but don't change position of element in LRU queue. More... | |
Element * | Put (const Key &key, Element *value) |
Caches element for key. If cache is full, return the removed element, otherwise return null. More... | |
Element * | Remove (const Key &key) |
Remove element for key. if it exist in the cache, return the element, otherwise return null. More... | |
Element * | ClearOne () |
Remove the Least Recently Used element in the cache. return the removed element or null. More... | |
bool | IsExist (const Key &key) |
Find element for key in the cache. If it exists, move it to the head of queue. More... | |
bool | ChangeCapacity (int capacity) |
Change cache's max capacity. New capacity must be larger than size in use. More... | |
unsigned int | Size () |
return cache's in use. More... | |
unsigned | Capacity () |
return cache's max capacity. More... | |
Static Public Member Functions | |
static bool | CacheL1Destroy (Element *value) |
static bool | CacheL2Destroy (Element *value) |
The data structure of the LRUCache.
using apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::DestroyFunc = std::function<bool(Element*)> |
|
inline |
The constructor.
|
inline |
The destructor.
|
inlinestatic |
|
inlinestatic |
|
inline |
return cache's max capacity.
|
inline |
Change cache's max capacity. New capacity must be larger than size in use.
Element * apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::ClearOne | ( | ) |
Remove the Least Recently Used element in the cache. return the removed element or null.
bool apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::Get | ( | const Key & | key, |
Element ** | value | ||
) |
Find element for key if it exists in the cache. If not exist, return false.
bool apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::GetSilent | ( | const Key & | key, |
Element ** | value | ||
) |
Find element for key if it exists in the cache. If not exist, return false. This function is thread safe, but don't change position of element in LRU queue.
bool apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::IsExist | ( | const Key & | key | ) |
Find element for key in the cache. If it exists, move it to the head of queue.
Element * apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::Put | ( | const Key & | key, |
Element * | value | ||
) |
Caches element for key. If cache is full, return the removed element, otherwise return null.
Element * apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::Remove | ( | const Key & | key | ) |
Remove element for key. if it exist in the cache, return the element, otherwise return null.
|
inline |
return cache's in use.