feat: added deletion of the first or last element

This commit is contained in:
aZholtikov committed 2026-07-19 17:51:09 +03:00
1 parent f46ab3f5fb
commit 1632cb4d28
6 files changed
+135 -5

No files matched your search

+32
View File
@@ -191,6 +191,38 @@ extern "C"
*/
esp_err_t zh_vector_delete_item(zh_vector_t **vector, uint16_t index);
/**
* @brief Removes the last element from the vector.
*
* The element's memory is freed. If the size drops below half of the capacity,
* the capacity is reduced (same behaviour as zh_vector_delete_item).
*
* @note Thread-safe: internally locks/unlocks the mutex.
*
* @param[in,out] vector Double pointer to vector structure (must be initialized).
*
* @return ESP_OK on success.
* @return ESP_ERR_INVALID_ARG if `vector == NULL` or `*vector == NULL` (not initialized) or vector is empty.
* @return ESP_ERR_INVALID_STATE if the internal mutex cannot be acquired.
*/
esp_err_t zh_vector_delete_back(zh_vector_t **vector);
/**
* @brief Removes the first element from the vector.
*
* The element's memory is freed, and all subsequent elements are shifted left by one.
* If the size drops below half of the capacity, the capacity is reduced (same behaviour as zh_vector_delete_item).
*
* @note Thread-safe: internally locks/unlocks the mutex.
*
* @param[in,out] vector Double pointer to vector structure (must be initialized).
*
* @return ESP_OK on success.
* @return ESP_ERR_INVALID_ARG if `vector == NULL` or `*vector == NULL` (not initialized) or vector is empty.
* @return ESP_ERR_INVALID_STATE if the internal mutex cannot be acquired.
*/
esp_err_t zh_vector_delete_front(zh_vector_t **vector);
/**
* @brief Removes duplicate items from the vector, keeping only the first occurrence of each value.
*