Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
uavcan::Map< Key, Value > Class Template Reference

#include <map.hpp>

Inheritance diagram for uavcan::Map< Key, Value >:
Inheritance graph
[legend]

Classes

struct  KVGroup
 
struct  KVPair
 
struct  YesPredicate
 

Public Member Functions

Value * access (const Key &key)
 
void clear ()
 
template<typename Predicate >
const Key * find (Predicate predicate) const
 
KVPairgetByIndex (unsigned index)
 
const KVPairgetByIndex (unsigned index) const
 
unsigned getSize () const
 
Value * insert (const Key &key, const Value &value)
 
bool isEmpty () const
 
 Map (IPoolAllocator &allocator)
 
void remove (const Key &key)
 
template<typename Predicate >
void removeAllWhere (Predicate predicate)
 
 ~Map ()
 

Private Member Functions

void compact ()
 
KVPairfindKey (const Key &key)
 
- Private Member Functions inherited from uavcan::Noncopyable
 Noncopyable ()
 
 ~Noncopyable ()
 

Private Attributes

IPoolAllocatorallocator_
 
LinkedListRoot< KVGrouplist_
 

Detailed Description

template<typename Key, typename Value>
class uavcan::Map< Key, Value >

Slow but memory efficient KV container.

KV pairs will be allocated in the node's memory pool.

Please be aware that this container does not perform any speed optimizations to minimize memory footprint, so the complexity of most operations is O(N).

Type requirements: Both key and value must be copyable, assignable and default constructible. Key must implement a comparison operator. Key's default constructor must initialize the object into invalid state. Size of Key + Value + padding must not exceed MemPoolBlockSize.

Definition at line 33 of file map.hpp.

Constructor & Destructor Documentation

◆ Map()

template<typename Key , typename Value >
uavcan::Map< Key, Value >::Map ( IPoolAllocator allocator)
inline

Definition at line 112 of file map.hpp.

◆ ~Map()

template<typename Key , typename Value >
uavcan::Map< Key, Value >::~Map ( )
inline

Definition at line 118 of file map.hpp.

Member Function Documentation

◆ access()

template<typename Key , typename Value >
Value * uavcan::Map< Key, Value >::access ( const Key &  key)

Returns null pointer if there's no such entry.

Definition at line 225 of file map.hpp.

◆ clear()

template<typename Key , typename Value >
void uavcan::Map< Key, Value >::clear

Removes all items.

Definition at line 327 of file map.hpp.

◆ compact()

template<typename Key , typename Value >
void uavcan::Map< Key, Value >::compact
private

Definition at line 200 of file map.hpp.

◆ find()

template<typename Key , typename Value >
template<typename Predicate >
const Key * uavcan::Map< Key, Value >::find ( Predicate  predicate) const

Returns first entry where the predicate returns true. Predicate prototype: bool (const Key& key, const Value& value)

Definition at line 302 of file map.hpp.

◆ findKey()

template<typename Key , typename Value >
Map< Key, Value >::KVPair * uavcan::Map< Key, Value >::findKey ( const Key &  key)
private

Definition at line 184 of file map.hpp.

◆ getByIndex() [1/2]

template<typename Key , typename Value >
Map< Key, Value >::KVPair * uavcan::Map< Key, Value >::getByIndex ( unsigned  index)

Returns a key-value pair located at the specified position from the beginning. Note that any insertion or deletion may greatly disturb internal ordering, so use with care. If index is greater than or equal the number of pairs, null pointer will be returned.

Definition at line 333 of file map.hpp.

◆ getByIndex() [2/2]

template<typename Key , typename Value >
const Map< Key, Value >::KVPair * uavcan::Map< Key, Value >::getByIndex ( unsigned  index) const

Definition at line 361 of file map.hpp.

◆ getSize()

template<typename Key , typename Value >
unsigned uavcan::Map< Key, Value >::getSize

Complexity is O(N).

Definition at line 367 of file map.hpp.

◆ insert()

template<typename Key , typename Value >
Value * uavcan::Map< Key, Value >::insert ( const Key &  key,
const Value &  value 
)

If entry with the same key already exists, it will be replaced

Definition at line 233 of file map.hpp.

◆ isEmpty()

template<typename Key , typename Value >
bool uavcan::Map< Key, Value >::isEmpty ( ) const
inline

Complexity is O(1).

Definition at line 170 of file map.hpp.

◆ remove()

template<typename Key , typename Value >
void uavcan::Map< Key, Value >::remove ( const Key &  key)

Does nothing if there's no such entry.

Definition at line 256 of file map.hpp.

◆ removeAllWhere()

template<typename Key , typename Value >
template<typename Predicate >
void uavcan::Map< Key, Value >::removeAllWhere ( Predicate  predicate)

Removes entries where the predicate returns true. Predicate prototype: bool (Key& key, Value& value)

Definition at line 269 of file map.hpp.

Member Data Documentation

◆ allocator_

template<typename Key , typename Value >
IPoolAllocator& uavcan::Map< Key, Value >::allocator_
private

Definition at line 100 of file map.hpp.

◆ list_

template<typename Key , typename Value >
LinkedListRoot<KVGroup> uavcan::Map< Key, Value >::list_
private

Definition at line 99 of file map.hpp.


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


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:04