https://github.com/azholtikov/zh_vector
ESP32 ESP-IDF component for vector (dynamic array).
https://github.com/azholtikov/zh_vector
component dynamic-array esp-idf vector
Last synced: about 2 months ago
JSON representation
ESP32 ESP-IDF component for vector (dynamic array).
- Host: GitHub
- URL: https://github.com/azholtikov/zh_vector
- Owner: aZholtikov
- License: apache-2.0
- Created: 2026-03-04T15:57:38.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-03-21T08:35:54.000Z (3 months ago)
- Last Synced: 2026-03-22T00:34:20.274Z (3 months ago)
- Topics: component, dynamic-array, esp-idf, vector
- Language: C
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ESP32 ESP-IDF component for vector (dynamic array)
## Tested on
1. [ESP32 ESP-IDF v6.0.0](https://docs.espressif.com/projects/esp-idf/en/v6.0/esp32/index.html)
## SAST Tools
[PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code.
## Features
1. Support of any data types.
2. The maximum size of the veсtor is 65535 elements.
## Using
In an existing project, run the following command to install the component:
```text
cd ../your_project/components
git clone https://github.com/aZholtikov/zh_vector
```
In the application, add the component:
```c
#include "zh_vector.h"
```
## Example
Create, add, read, modify and delete items:
```c
#include "zh_vector.h"
zh_vector_t vector = {0};
char example[10] = {0};
void app_main(void)
{
esp_log_level_set("zh_vector", ESP_LOG_ERROR);
zh_vector_init(&vector, sizeof(example));
printf("Initial vector size is: %d\n", zh_vector_get_size(&vector));
strcpy(example, "Item 1");
zh_vector_push_back(&vector, &example);
strcpy(example, "Item 2");
zh_vector_push_back(&vector, &example);
strcpy(example, "Item 3");
zh_vector_push_back(&vector, &example);
strcpy(example, "Item 4");
zh_vector_push_back(&vector, &example);
strcpy(example, "Item 5");
zh_vector_push_back(&vector, &example);
printf("Add 5 items. New vector size is: %d\n", zh_vector_get_size(&vector));
for (uint16_t i = 0; i < zh_vector_get_size(&vector); ++i)
{
printf("Item position %d is: %s\n", i, (char *)zh_vector_get_item(&vector, i));
}
strcpy(example, "Item 6");
zh_vector_change_item(&vector, 3, &example);
printf("Change item on 3 position.\n");
for (uint16_t i = 0; i < zh_vector_get_size(&vector); ++i)
{
printf("Item position %d is: %s\n", i, (char *)zh_vector_get_item(&vector, i));
}
zh_vector_delete_item(&vector, 2);
printf("Delete item on 2 position. New vector size is: %d\n", zh_vector_get_size(&vector));
for (uint16_t i = 0; i < zh_vector_get_size(&vector); ++i)
{
printf("Item position %d is: %s\n", i, (char *)zh_vector_get_item(&vector, i));
}
zh_vector_free(&vector);
}
```