muwerk ustd Library
A low-resource, minimal implementation of Arrays, Maps and Queues for low-resource avrs.
|
Lightweight c++11 dictionary map implementation. More...
#include <ustd_map.h>
Public Member Functions | |
map (unsigned int startSize=ARRAY_INIT_SIZE, unsigned int maxSize=ARRAY_MAX_SIZE, unsigned int incSize=ARRAY_INC_SIZE, bool shrink=true) | |
~map () | |
V | operator[] (K key) const |
V & | operator[] (K key) |
int | find (K key) |
int | erase (K key) |
void | setInvalidValue (V &entryInvalidValue) |
bool | isEmpty () |
const ustd::array< K > & | keysArray () |
unsigned int | length () |
unsigned int | peak () |
Public Attributes | |
ustd::array< V > | values |
Lightweight c++11 dictionary map implementation.
ustd_map.h is a minimal, yet highly portable dictionary map type implementation that runs well on architectures with very limited resources such as attiny 8kb avr.
The map class either:
The library header-only.
Make sure to provide the required platform define before including ustd headers.
|
inline |
Array of values
Constructs a map object. All allocation-hints are optional, the array class used by map will allocate memory as needed during writes, if startSize!=maxSize.
startSize | The number of map entries that are allocated during object creation |
maxSize | The maximal limit of records that will be allocated. If startSize < maxSize, the map size will grow automatically as needed. |
incSize | The number of map entries that are allocated as a chunk if the map needs to grow |
shrink | Boolean indicating, if the map should deallocate memory, if the map size shrinks (due to erase()). |
|
inline |
Delete the entry corresponding to map-key. This might lead to memory-deallocation, if shrink=True during map creation
key | Map-key of entry to be deleted |
|
inline |
Get the index of the key and value arrays of the map
key | Map-key. |
|
inline |
Check, if map is empty.
|
inline |
Reference to array of keys
|
inline |
Check number of map-members.
|
inline |
Write a map value for a given key
key | map-key |
|
inline |
Read value of map for given key, a=myMap[3].
key | map-key |
|
inline |
Check peak number of map-members.
|
inline |
Set the value that's given back, if read of an invalid key is requested. By default, an entry all set to zero is given back. Using this function, the value of an invalid read can be configured.
entryInvalidValue | The value that is given back in case an invalid operation (e.g. read out of invalid key) is tried. |
ustd::array<V> ustd::map< K, V >::values |
Array of keys