Apollo  6.0
Open source self driving car software
Public Types | Public Member Functions | Static Public Member Functions | List of all members
apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache > Class Template Reference

The data structure of the LRUCache. More...

#include <base_map_cache.h>

Collaboration diagram for apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >:
Collaboration graph

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)
 

Detailed Description

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
class apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >

The data structure of the LRUCache.

Member Typedef Documentation

◆ DestroyFunc

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
using apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::DestroyFunc = std::function<bool(Element*)>

Constructor & Destructor Documentation

◆ MapNodeCache()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::MapNodeCache ( unsigned int  capacity,
const DestroyFunc destroy_func 
)
inline

The constructor.

◆ ~MapNodeCache()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::~MapNodeCache ( )
inline

The destructor.

Member Function Documentation

◆ CacheL1Destroy()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
static bool apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::CacheL1Destroy ( Element *  value)
inlinestatic

◆ CacheL2Destroy()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
static bool apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::CacheL2Destroy ( Element *  value)
inlinestatic

◆ Capacity()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
unsigned apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::Capacity ( )
inline

return cache's max capacity.

◆ ChangeCapacity()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
bool apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::ChangeCapacity ( int  capacity)
inline

Change cache's max capacity. New capacity must be larger than size in use.

◆ ClearOne()

template<class Key , class Element , class MapLRUCache >
Element * apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::ClearOne ( )

Remove the Least Recently Used element in the cache. return the removed element or null.

◆ Get()

template<class Key, class Element, class MapLRUCache >
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.

◆ GetSilent()

template<class Key, class Element, class MapLRUCache >
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.

◆ IsExist()

template<class Key, class Element , class MapLRUCache >
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.

◆ Put()

template<class Key, class Element, class MapLRUCache >
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.

◆ Remove()

template<class Key, class Element , class MapLRUCache >
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.

◆ Size()

template<class Key, class Element, class MapLRUCache = LRUCache<Key, Element>>
unsigned int apollo::localization::msf::MapNodeCache< Key, Element, MapLRUCache >::Size ( )
inline

return cache's in use.


The documentation for this class was generated from the following file: