Container Map
This file contains a set of functions to perform the Container Map-specific APIs.
The container map functionalities are based on a sorted singly linked list concept.
The first four bytes of memory are reserved (0 to 3). From the next byte onwards, data is structured as single nodes.
Each node contains a header, key, and value.
Map Structure Format
In map buffer, the structure format of map contains header, key and value. The key and value has different size. Following is the cases that container map supports different types of key-value pair structures:
- Case 1 - Key and Value (Except String or Complex Data Types)
Header - 4 bytes (default)
Key - Depends on the key data size
Value - Depends on the value data size
This is considered a single node.
- Case 2 - Key and Value (String or Complex Data Types like Arrays, Structures, etc.)
Header - 4 bytes (default)
Key Length - 1 byte
Key - Depends on the key length
Value Length - 1 byte
Value - Depends on the value length
This is considered a single node.
- Case 3 - Key (String) and Value (Fixed Data Type: uint8, int8, uint16, int16, uint32, int32, float, double)
Header - 4 bytes (default)
Key Length - 1 byte
Key - Depends on the key size
Value - Fixed data type size
This is considered a single node.
- Case 4 - Key (Fixed Data Type) and Value (String)
Header - 4 bytes (default)
Key - Depends on the key size
Value Length - 1 byte
Value - Depends on the value length
This is considered a single node.
Usage
All API functions use the first argument as the container map instance.
The container is initialized with a specified maximum capacity.
Data is inserted using a key-value pair mechanism.
Supports retrieval, deletion, and checking the existence of keys.
Ensures efficient space utilization by reusing deleted slots.
Return codes of API functions are defined in the header file .
Function |
Description |
|---|---|
rs_map_init |
Function to initialize the container map with a given size |
rs_map_set |
Function to insert a key-value pair into the container map |
rs_map_get |
Function to retrieve a value based on the key |
rs_map_erase |
Function to delete a key-value pair from the container map |
rs_map_erase_all |
Function to delete all key-value pair from the container map |
rs_map_get_num_entries |
Function to get the current number of entries in the container map |
rs_map_is_full |
Function to check if the container map is full |
Features Supported
The container map supports dynamic key-value storage.
Efficient deletion mechanism ensures space is reused.
Allows querying whether a key exists before accessing.
Supports fixed or variable-sized storage for values.
Provides a method to clear all stored entries when needed.
Limitations
Container Map (Key - string data type, Value - string/any data type) Set support only for fresh new node (Erased old free node not supported)
Error Code
Every API function for the container map module returns success or failure values. Please refer to the following section:
Example Demo
Please refer to the following section:
Container Map Header Details
Documentation from the relevant header is as follows:
Warning
doxygenfile: Cannot find file “rs_map.h