From 07bf829618399f524f2ade36b3949a743e5a6bcf Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sun, 20 Oct 2024 16:23:59 -0500 Subject: [PATCH] add missing info regarding o of n --- code/logic/fossil/tofu/arrayof.h | 8 ++++++++ code/logic/fossil/tofu/doublylist.h | 14 +++++++++++++ code/logic/fossil/tofu/dqueue.h | 12 +++++++++++ code/logic/fossil/tofu/forwardlist.h | 14 +++++++++++++ code/logic/fossil/tofu/mapof.h | 10 ++++++++++ code/logic/fossil/tofu/pqueue.h | 12 +++++++++++ code/logic/fossil/tofu/queue.h | 12 +++++++++++ code/logic/fossil/tofu/setof.h | 13 ++++++++++++ code/logic/fossil/tofu/stack.h | 13 ++++++++++++ code/logic/fossil/tofu/tofu.h | 30 ++++++++++++++++++++++++++++ code/logic/fossil/tofu/vector.h | 26 ++++++++++++++++++++++++ 11 files changed, 164 insertions(+) diff --git a/code/logic/fossil/tofu/arrayof.h b/code/logic/fossil/tofu/arrayof.h index b47b5e6..b2955fa 100644 --- a/code/logic/fossil/tofu/arrayof.h +++ b/code/logic/fossil/tofu/arrayof.h @@ -35,6 +35,7 @@ typedef struct { * @param size The number of initial elements. * @param ... The initial values for the elements. * @return A newly created fossil_tofu_arrayof_t. + * @note Time complexity: O(n), where n is the number of initial elements. */ fossil_tofu_arrayof_t fossil_tofu_arrayof_create(char *type, size_t size, ...); @@ -42,6 +43,7 @@ fossil_tofu_arrayof_t fossil_tofu_arrayof_create(char *type, size_t size, ...); * @brief Destroys the arrayof and frees allocated memory. * * @param arrayof A pointer to the fossil_tofu_arrayof_t to be destroyed. + * @note Time complexity: O(1). */ void fossil_tofu_arrayof_erase(fossil_tofu_arrayof_t *arrayof); @@ -50,6 +52,7 @@ void fossil_tofu_arrayof_erase(fossil_tofu_arrayof_t *arrayof); * * @param arrayof A pointer to the fossil_tofu_arrayof_t. * @param tofu The fossil_tofu_t element to add. + * @note Time complexity: O(1) on average, O(n) in the worst case when resizing. */ void fossil_tofu_arrayof_add(fossil_tofu_arrayof_t *arrayof, fossil_tofu_t tofu); @@ -59,6 +62,7 @@ void fossil_tofu_arrayof_add(fossil_tofu_arrayof_t *arrayof, fossil_tofu_t tofu) * @param arrayof A pointer to the fossil_tofu_arrayof_t. * @param index The index of the element to retrieve. * @return The fossil_tofu_t element at the specified index. + * @note Time complexity: O(1). */ fossil_tofu_t fossil_tofu_arrayof_get(const fossil_tofu_arrayof_t *arrayof, size_t index); @@ -67,6 +71,7 @@ fossil_tofu_t fossil_tofu_arrayof_get(const fossil_tofu_arrayof_t *arrayof, size * * @param arrayof A pointer to the fossil_tofu_arrayof_t. * @return The current number of elements in the arrayof. + * @note Time complexity: O(1). */ size_t fossil_tofu_arrayof_size(const fossil_tofu_arrayof_t *arrayof); @@ -75,6 +80,7 @@ size_t fossil_tofu_arrayof_size(const fossil_tofu_arrayof_t *arrayof); * * @param arrayof A pointer to the fossil_tofu_arrayof_t. * @return True if the arrayof is empty, false otherwise. + * @note Time complexity: O(1). */ bool fossil_tofu_arrayof_is_empty(const fossil_tofu_arrayof_t *arrayof); @@ -82,6 +88,7 @@ bool fossil_tofu_arrayof_is_empty(const fossil_tofu_arrayof_t *arrayof); * @brief Clears all elements from the arrayof. * * @param arrayof A pointer to the fossil_tofu_arrayof_t. + * @note Time complexity: O(n), where n is the number of elements in the array. */ void fossil_tofu_arrayof_clear(fossil_tofu_arrayof_t *arrayof); @@ -89,6 +96,7 @@ void fossil_tofu_arrayof_clear(fossil_tofu_arrayof_t *arrayof); * @brief Prints all elements of the arrayof. * * @param arrayof A pointer to the fossil_tofu_arrayof_t. + * @note Time complexity: O(n), where n is the number of elements in the array. */ void fossil_tofu_arrayof_print(const fossil_tofu_arrayof_t *arrayof); diff --git a/code/logic/fossil/tofu/doublylist.h b/code/logic/fossil/tofu/doublylist.h index c1c8a9c..d0f10ee 100644 --- a/code/logic/fossil/tofu/doublylist.h +++ b/code/logic/fossil/tofu/doublylist.h @@ -40,6 +40,7 @@ typedef struct fossil_dlist_t { * * @param list_type The type of data the doubly linked list will store. * @return The created doubly linked list. + * @note Time complexity: O(1) */ fossil_dlist_t* fossil_dlist_create(char* type); @@ -47,6 +48,7 @@ fossil_dlist_t* fossil_dlist_create(char* type); * Erase the contents of the doubly linked list and free allocated memory. * * @param dlist The doubly linked list to erase. + * @note Time complexity: O(n) */ void fossil_dlist_erase(fossil_dlist_t* dlist); @@ -56,6 +58,7 @@ void fossil_dlist_erase(fossil_dlist_t* dlist); * @param dlist The doubly linked list to insert data into. * @param data The data to insert. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_dlist_insert(fossil_dlist_t* dlist, fossil_tofu_t data); @@ -65,6 +68,7 @@ int32_t fossil_dlist_insert(fossil_dlist_t* dlist, fossil_tofu_t data); * @param dlist The doubly linked list to remove data from. * @param data A pointer to store the removed data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_dlist_remove(fossil_dlist_t* dlist, fossil_tofu_t* data); @@ -74,6 +78,7 @@ int32_t fossil_dlist_remove(fossil_dlist_t* dlist, fossil_tofu_t* data); * @param dlist The doubly linked list to search. * @param data The data to search for. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_dlist_search(const fossil_dlist_t* dlist, fossil_tofu_t data); @@ -81,6 +86,7 @@ int32_t fossil_dlist_search(const fossil_dlist_t* dlist, fossil_tofu_t data); * Reverse the doubly linked list in the forward direction. * * @param dlist The doubly linked list to reverse. + * @note Time complexity: O(n) */ void fossil_dlist_reverse_forward(fossil_dlist_t* dlist); @@ -88,6 +94,7 @@ void fossil_dlist_reverse_forward(fossil_dlist_t* dlist); * Reverse the doubly linked list in the backward direction. * * @param dlist The doubly linked list to reverse. + * @note Time complexity: O(n) */ void fossil_dlist_reverse_backward(fossil_dlist_t* dlist); @@ -96,6 +103,7 @@ void fossil_dlist_reverse_backward(fossil_dlist_t* dlist); * * @param dlist The doubly linked list for which to get the size. * @return The size of the doubly linked list. + * @note Time complexity: O(n) */ size_t fossil_dlist_size(const fossil_dlist_t* dlist); @@ -105,6 +113,7 @@ size_t fossil_dlist_size(const fossil_dlist_t* dlist); * @param dlist The doubly linked list from which to get the data. * @param data The data to search for. * @return A pointer to the matching data. + * @note Time complexity: O(n) */ fossil_tofu_t* fossil_dlist_getter(fossil_dlist_t* dlist, fossil_tofu_t data); @@ -114,6 +123,7 @@ fossil_tofu_t* fossil_dlist_getter(fossil_dlist_t* dlist, fossil_tofu_t data); * @param dlist The doubly linked list in which to set the data. * @param data The data to set. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_dlist_setter(fossil_dlist_t* dlist, fossil_tofu_t data); @@ -122,6 +132,7 @@ int32_t fossil_dlist_setter(fossil_dlist_t* dlist, fossil_tofu_t data); * * @param dlist The doubly linked list to check. * @return True if the doubly linked list is not empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dlist_not_empty(const fossil_dlist_t* dlist); @@ -130,6 +141,7 @@ bool fossil_dlist_not_empty(const fossil_dlist_t* dlist); * * @param dlist The doubly linked list to check. * @return True if the doubly linked list is not a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dlist_not_cnullptr(const fossil_dlist_t* dlist); @@ -138,6 +150,7 @@ bool fossil_dlist_not_cnullptr(const fossil_dlist_t* dlist); * * @param dlist The doubly linked list to check. * @return True if the doubly linked list is empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dlist_is_empty(const fossil_dlist_t* dlist); @@ -146,6 +159,7 @@ bool fossil_dlist_is_empty(const fossil_dlist_t* dlist); * * @param dlist The doubly linked list to check. * @return True if the doubly linked list is a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dlist_is_cnullptr(const fossil_dlist_t* dlist); diff --git a/code/logic/fossil/tofu/dqueue.h b/code/logic/fossil/tofu/dqueue.h index d120c19..61c5450 100644 --- a/code/logic/fossil/tofu/dqueue.h +++ b/code/logic/fossil/tofu/dqueue.h @@ -40,6 +40,7 @@ typedef struct fossil_dqueue_t { * * @param list_type The type of data the dynamic queue will store. * @return The created dynamic queue. + * @note Time complexity: O(1) */ fossil_dqueue_t* fossil_dqueue_create(char* type); @@ -47,6 +48,7 @@ fossil_dqueue_t* fossil_dqueue_create(char* type); * Erase the contents of the dynamic queue and free allocated memory. * * @param dqueue The dynamic queue to erase. + * @note Time complexity: O(n) */ void fossil_dqueue_erase(fossil_dqueue_t* dqueue); @@ -56,6 +58,7 @@ void fossil_dqueue_erase(fossil_dqueue_t* dqueue); * @param dqueue The dynamic queue to insert data into. * @param data The data to insert. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_dqueue_insert(fossil_dqueue_t* dqueue, fossil_tofu_t data); @@ -65,6 +68,7 @@ int32_t fossil_dqueue_insert(fossil_dqueue_t* dqueue, fossil_tofu_t data); * @param dqueue The dynamic queue to remove data from. * @param data A pointer to store the removed data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_dqueue_remove(fossil_dqueue_t* dqueue, fossil_tofu_t* data); @@ -74,6 +78,7 @@ int32_t fossil_dqueue_remove(fossil_dqueue_t* dqueue, fossil_tofu_t* data); * @param dqueue The dynamic queue to search. * @param data The data to search for. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_dqueue_search(const fossil_dqueue_t* dqueue, fossil_tofu_t data); @@ -82,6 +87,7 @@ int32_t fossil_dqueue_search(const fossil_dqueue_t* dqueue, fossil_tofu_t data); * * @param dqueue The dynamic queue for which to get the size. * @return The size of the dynamic queue. + * @note Time complexity: O(1) */ size_t fossil_dqueue_size(const fossil_dqueue_t* dqueue); @@ -91,6 +97,7 @@ size_t fossil_dqueue_size(const fossil_dqueue_t* dqueue); * @param dqueue The dynamic queue from which to get the data. * @param data The data to search for. * @return A pointer to the matching data. + * @note Time complexity: O(n) */ fossil_tofu_t* fossil_dqueue_getter(fossil_dqueue_t* dqueue, fossil_tofu_t data); @@ -100,6 +107,7 @@ fossil_tofu_t* fossil_dqueue_getter(fossil_dqueue_t* dqueue, fossil_tofu_t data) * @param dqueue The dynamic queue in which to set the data. * @param data The data to set. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_dqueue_setter(fossil_dqueue_t* dqueue, fossil_tofu_t data); @@ -108,6 +116,7 @@ int32_t fossil_dqueue_setter(fossil_dqueue_t* dqueue, fossil_tofu_t data); * * @param dqueue The dynamic queue to check. * @return True if the dynamic queue is not empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dqueue_not_empty(const fossil_dqueue_t* dqueue); @@ -116,6 +125,7 @@ bool fossil_dqueue_not_empty(const fossil_dqueue_t* dqueue); * * @param dqueue The dynamic queue to check. * @return True if the dynamic queue is not a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dqueue_not_cnullptr(const fossil_dqueue_t* dqueue); @@ -124,6 +134,7 @@ bool fossil_dqueue_not_cnullptr(const fossil_dqueue_t* dqueue); * * @param dqueue The dynamic queue to check. * @return True if the dynamic queue is empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dqueue_is_empty(const fossil_dqueue_t* dqueue); @@ -132,6 +143,7 @@ bool fossil_dqueue_is_empty(const fossil_dqueue_t* dqueue); * * @param dqueue The dynamic queue to check. * @return True if the dynamic queue is a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_dqueue_is_cnullptr(const fossil_dqueue_t* dqueue); diff --git a/code/logic/fossil/tofu/forwardlist.h b/code/logic/fossil/tofu/forwardlist.h index 2205799..311a097 100644 --- a/code/logic/fossil/tofu/forwardlist.h +++ b/code/logic/fossil/tofu/forwardlist.h @@ -38,6 +38,7 @@ typedef struct fossil_flist_t { * * @param list_type The type of data the forward list will store. * @return The created forward list. + * @complexity O(1) */ fossil_flist_t* fossil_flist_create(char* type); @@ -45,6 +46,7 @@ fossil_flist_t* fossil_flist_create(char* type); * Erase the contents of the forward list and free allocated memory. * * @param flist The forward list to erase. + * @complexity O(n) */ void fossil_flist_erase(fossil_flist_t* flist); @@ -54,6 +56,7 @@ void fossil_flist_erase(fossil_flist_t* flist); * @param flist The forward list to insert data into. * @param data The data to insert. * @return The error code indicating the success or failure of the operation. + * @complexity O(1) */ int32_t fossil_flist_insert(fossil_flist_t* flist, fossil_tofu_t data); @@ -63,6 +66,7 @@ int32_t fossil_flist_insert(fossil_flist_t* flist, fossil_tofu_t data); * @param flist The forward list to remove data from. * @param data A pointer to store the removed data. * @return The error code indicating the success or failure of the operation. + * @complexity O(1) */ int32_t fossil_flist_remove(fossil_flist_t* flist, fossil_tofu_t* data); @@ -72,6 +76,7 @@ int32_t fossil_flist_remove(fossil_flist_t* flist, fossil_tofu_t* data); * @param flist The forward list to search. * @param data The data to search for. * @return The error code indicating the success or failure of the operation. + * @complexity O(n) */ int32_t fossil_flist_search(const fossil_flist_t* flist, fossil_tofu_t data); @@ -79,6 +84,7 @@ int32_t fossil_flist_search(const fossil_flist_t* flist, fossil_tofu_t data); * Reverse the forward list in the forward direction. * * @param flist The forward list to reverse. + * @complexity O(n) */ void fossil_flist_reverse_forward(fossil_flist_t* flist); @@ -86,6 +92,7 @@ void fossil_flist_reverse_forward(fossil_flist_t* flist); * Reverse the forward list in the backward direction. * * @param flist The forward list to reverse. + * @complexity O(n) */ void fossil_flist_reverse_backward(fossil_flist_t* flist); @@ -94,6 +101,7 @@ void fossil_flist_reverse_backward(fossil_flist_t* flist); * * @param flist The forward list for which to get the size. * @return The size of the forward list. + * @complexity O(n) */ size_t fossil_flist_size(const fossil_flist_t* flist); @@ -103,6 +111,7 @@ size_t fossil_flist_size(const fossil_flist_t* flist); * @param flist The forward list from which to get the data. * @param data The data to search for. * @return A pointer to the matching data. + * @complexity O(n) */ fossil_tofu_t* fossil_flist_getter(fossil_flist_t* flist, fossil_tofu_t data); @@ -112,6 +121,7 @@ fossil_tofu_t* fossil_flist_getter(fossil_flist_t* flist, fossil_tofu_t data); * @param flist The forward list in which to set the data. * @param data The data to set. * @return The error code indicating the success or failure of the operation. + * @complexity O(n) */ int32_t fossil_flist_setter(fossil_flist_t* flist, fossil_tofu_t data); @@ -120,6 +130,7 @@ int32_t fossil_flist_setter(fossil_flist_t* flist, fossil_tofu_t data); * * @param flist The forward list to check. * @return True if the forward list is not empty, false otherwise. + * @complexity O(1) */ bool fossil_flist_not_empty(const fossil_flist_t* flist); @@ -128,6 +139,7 @@ bool fossil_flist_not_empty(const fossil_flist_t* flist); * * @param flist The forward list to check. * @return True if the forward list is not a null pointer, false otherwise. + * @complexity O(1) */ bool fossil_flist_not_cnullptr(const fossil_flist_t* flist); @@ -136,6 +148,7 @@ bool fossil_flist_not_cnullptr(const fossil_flist_t* flist); * * @param flist The forward list to check. * @return True if the forward list is empty, false otherwise. + * @complexity O(1) */ bool fossil_flist_is_empty(const fossil_flist_t* flist); @@ -144,6 +157,7 @@ bool fossil_flist_is_empty(const fossil_flist_t* flist); * * @param flist The forward list to check. * @return True if the forward list is a null pointer, false otherwise. + * @complexity O(1) */ bool fossil_flist_is_cnullptr(const fossil_flist_t* flist); diff --git a/code/logic/fossil/tofu/mapof.h b/code/logic/fossil/tofu/mapof.h index 957e2df..3c10bfb 100644 --- a/code/logic/fossil/tofu/mapof.h +++ b/code/logic/fossil/tofu/mapof.h @@ -34,6 +34,7 @@ typedef struct { * * @param type The type of the map. * @return The created map. + * @note Time complexity: O(1) */ fossil_tofu_mapof_t fossil_tofu_mapof_create(const char *type); @@ -43,6 +44,7 @@ fossil_tofu_mapof_t fossil_tofu_mapof_create(const char *type); * @param map The map to add the key-value pair to. * @param key The key to add. * @param value The value to add. + * @note Time complexity: O(1) on average, O(n) in the worst case due to resizing. */ void fossil_tofu_mapof_add(fossil_tofu_mapof_t *map, fossil_tofu_t key, fossil_tofu_t value); @@ -52,6 +54,7 @@ void fossil_tofu_mapof_add(fossil_tofu_mapof_t *map, fossil_tofu_t key, fossil_t * @param map The map to get the value from. * @param key The key to get the value for. * @return The value associated with the key, or NULL if the key is not found. + * @note Time complexity: O(1) on average, O(n) in the worst case. */ fossil_tofu_t fossil_tofu_mapof_get(fossil_tofu_mapof_t *map, fossil_tofu_t key); @@ -61,6 +64,7 @@ fossil_tofu_t fossil_tofu_mapof_get(fossil_tofu_mapof_t *map, fossil_tofu_t key) * @param map The map to check. * @param key The key to check for. * @return true if the key exists in the map, false otherwise. + * @note Time complexity: O(1) on average, O(n) in the worst case. */ bool fossil_tofu_mapof_contains(fossil_tofu_mapof_t *map, fossil_tofu_t key); @@ -69,6 +73,7 @@ bool fossil_tofu_mapof_contains(fossil_tofu_mapof_t *map, fossil_tofu_t key); * * @param map The map to remove the key-value pair from. * @param key The key to remove. + * @note Time complexity: O(1) on average, O(n) in the worst case. */ void fossil_tofu_mapof_remove(fossil_tofu_mapof_t *map, fossil_tofu_t key); @@ -77,6 +82,7 @@ void fossil_tofu_mapof_remove(fossil_tofu_mapof_t *map, fossil_tofu_t key); * * @param map The map to get the size of. * @return The number of key-value pairs in the map. + * @note Time complexity: O(1) */ size_t fossil_tofu_mapof_size(fossil_tofu_mapof_t *map); @@ -85,6 +91,7 @@ size_t fossil_tofu_mapof_size(fossil_tofu_mapof_t *map); * * @param map The map to check. * @return true if the map is empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_tofu_mapof_is_empty(fossil_tofu_mapof_t *map); @@ -92,6 +99,7 @@ bool fossil_tofu_mapof_is_empty(fossil_tofu_mapof_t *map); * @brief Clears all key-value pairs from the map. * * @param map The map to clear. + * @note Time complexity: O(n) */ void fossil_tofu_mapof_clear(fossil_tofu_mapof_t *map); @@ -99,6 +107,7 @@ void fossil_tofu_mapof_clear(fossil_tofu_mapof_t *map); * @brief Destroys the map and frees the allocated memory. * * @param map The map to destroy. + * @note Time complexity: O(n) */ void fossil_tofu_mapof_erase(fossil_tofu_mapof_t *map); @@ -106,6 +115,7 @@ void fossil_tofu_mapof_erase(fossil_tofu_mapof_t *map); * @brief Prints the contents of the map. * * @param map The map to print. + * @note Time complexity: O(n) */ void fossil_tofu_mapof_print(fossil_tofu_mapof_t *map); diff --git a/code/logic/fossil/tofu/pqueue.h b/code/logic/fossil/tofu/pqueue.h index ab384be..cff7012 100644 --- a/code/logic/fossil/tofu/pqueue.h +++ b/code/logic/fossil/tofu/pqueue.h @@ -37,6 +37,7 @@ typedef struct fossil_pqueue_t { * * @param queue_type The type of data the priority queue will store. * @return The created priority queue. + * @note Time complexity: O(1) */ fossil_pqueue_t* fossil_pqueue_create(char* type); @@ -44,6 +45,7 @@ fossil_pqueue_t* fossil_pqueue_create(char* type); * Erase the contents of the priority queue and free allocated memory. * * @param pqueue The priority queue to erase. + * @note Time complexity: O(n) */ void fossil_pqueue_erase(fossil_pqueue_t* pqueue); @@ -54,6 +56,7 @@ void fossil_pqueue_erase(fossil_pqueue_t* pqueue); * @param data The data to insert. * @param priority The priority of the data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_pqueue_insert(fossil_pqueue_t* pqueue, fossil_tofu_t data, int32_t priority); @@ -64,6 +67,7 @@ int32_t fossil_pqueue_insert(fossil_pqueue_t* pqueue, fossil_tofu_t data, int32_ * @param data The data to remove. * @param priority The priority of the data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_pqueue_remove(fossil_pqueue_t* pqueue, fossil_tofu_t* data, int32_t priority); @@ -74,6 +78,7 @@ int32_t fossil_pqueue_remove(fossil_pqueue_t* pqueue, fossil_tofu_t* data, int32 * @param data The data to search for. * @param priority The priority of the data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_pqueue_search(const fossil_pqueue_t* pqueue, fossil_tofu_t data, int32_t priority); @@ -82,6 +87,7 @@ int32_t fossil_pqueue_search(const fossil_pqueue_t* pqueue, fossil_tofu_t data, * * @param pqueue The priority queue for which to get the size. * @return The size of the priority queue. + * @note Time complexity: O(1) */ size_t fossil_pqueue_size(const fossil_pqueue_t* pqueue); @@ -92,6 +98,7 @@ size_t fossil_pqueue_size(const fossil_pqueue_t* pqueue); * @param data The data to search for. * @param priority The priority of the data. * @return A pointer to the matching data, or NULL if not found. + * @note Time complexity: O(n) */ fossil_tofu_t* fossil_pqueue_getter(fossil_pqueue_t* pqueue, fossil_tofu_t data, int32_t priority); @@ -102,6 +109,7 @@ fossil_tofu_t* fossil_pqueue_getter(fossil_pqueue_t* pqueue, fossil_tofu_t data, * @param data The data to set. * @param priority The priority of the data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_pqueue_setter(fossil_pqueue_t* pqueue, fossil_tofu_t data, int32_t priority); @@ -110,6 +118,7 @@ int32_t fossil_pqueue_setter(fossil_pqueue_t* pqueue, fossil_tofu_t data, int32_ * * @param pqueue The priority queue to check. * @return True if the priority queue is not empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_pqueue_not_empty(const fossil_pqueue_t* pqueue); @@ -118,6 +127,7 @@ bool fossil_pqueue_not_empty(const fossil_pqueue_t* pqueue); * * @param pqueue The priority queue to check. * @return True if the priority queue is not a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_pqueue_not_cnullptr(const fossil_pqueue_t* pqueue); @@ -126,6 +136,7 @@ bool fossil_pqueue_not_cnullptr(const fossil_pqueue_t* pqueue); * * @param pqueue The priority queue to check. * @return True if the priority queue is empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_pqueue_is_empty(const fossil_pqueue_t* pqueue); @@ -134,6 +145,7 @@ bool fossil_pqueue_is_empty(const fossil_pqueue_t* pqueue); * * @param pqueue The priority queue to check. * @return True if the priority queue is a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_pqueue_is_cnullptr(const fossil_pqueue_t* pqueue); diff --git a/code/logic/fossil/tofu/queue.h b/code/logic/fossil/tofu/queue.h index d89d920..d09a136 100644 --- a/code/logic/fossil/tofu/queue.h +++ b/code/logic/fossil/tofu/queue.h @@ -39,6 +39,7 @@ typedef struct fossil_queue_t { * * @param list_type The type of data the queue will store. * @return The created queue. + * @note Time complexity: O(1) */ fossil_queue_t* fossil_queue_create(char* type); @@ -46,6 +47,7 @@ fossil_queue_t* fossil_queue_create(char* type); * Erase the contents of the queue and free allocated memory. * * @param queue The queue to erase. + * @note Time complexity: O(n) */ void fossil_queue_erase(fossil_queue_t* queue); @@ -55,6 +57,7 @@ void fossil_queue_erase(fossil_queue_t* queue); * @param queue The queue to insert data into. * @param data The data to insert. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_queue_insert(fossil_queue_t* queue, fossil_tofu_t data); @@ -64,6 +67,7 @@ int32_t fossil_queue_insert(fossil_queue_t* queue, fossil_tofu_t data); * @param queue The queue to remove data from. * @param data The data to remove. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_queue_remove(fossil_queue_t* queue, fossil_tofu_t* data); @@ -73,6 +77,7 @@ int32_t fossil_queue_remove(fossil_queue_t* queue, fossil_tofu_t* data); * @param queue The queue to search. * @param data The data to search for. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_queue_search(const fossil_queue_t* queue, fossil_tofu_t data); @@ -81,6 +86,7 @@ int32_t fossil_queue_search(const fossil_queue_t* queue, fossil_tofu_t data); * * @param queue The queue for which to get the size. * @return The size of the queue. + * @note Time complexity: O(n) */ size_t fossil_queue_size(const fossil_queue_t* queue); @@ -90,6 +96,7 @@ size_t fossil_queue_size(const fossil_queue_t* queue); * @param queue The queue from which to get the data. * @param data The data to search for. * @return A pointer to the matching data, or NULL if not found. + * @note Time complexity: O(n) */ fossil_tofu_t* fossil_queue_getter(fossil_queue_t* queue, fossil_tofu_t data); @@ -99,6 +106,7 @@ fossil_tofu_t* fossil_queue_getter(fossil_queue_t* queue, fossil_tofu_t data); * @param queue The queue in which to set the data. * @param data The data to set. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_queue_setter(fossil_queue_t* queue, fossil_tofu_t data); @@ -107,6 +115,7 @@ int32_t fossil_queue_setter(fossil_queue_t* queue, fossil_tofu_t data); * * @param queue The queue to check. * @return True if the queue is not empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_queue_not_empty(const fossil_queue_t* queue); @@ -115,6 +124,7 @@ bool fossil_queue_not_empty(const fossil_queue_t* queue); * * @param queue The queue to check. * @return True if the queue is not a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_queue_not_cnullptr(const fossil_queue_t* queue); @@ -123,6 +133,7 @@ bool fossil_queue_not_cnullptr(const fossil_queue_t* queue); * * @param queue The queue to check. * @return True if the queue is empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_queue_is_empty(const fossil_queue_t* queue); @@ -131,6 +142,7 @@ bool fossil_queue_is_empty(const fossil_queue_t* queue); * * @param queue The queue to check. * @return True if the queue is a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_queue_is_cnullptr(const fossil_queue_t* queue); diff --git a/code/logic/fossil/tofu/setof.h b/code/logic/fossil/tofu/setof.h index 13367bd..3ffdf24 100644 --- a/code/logic/fossil/tofu/setof.h +++ b/code/logic/fossil/tofu/setof.h @@ -38,6 +38,7 @@ typedef struct fossil_set_t { * * @param list_type The type of data the set will store. * @return The created set. + * @note O(1) - Constant time complexity. */ fossil_set_t* fossil_set_create(char* type); @@ -45,6 +46,7 @@ fossil_set_t* fossil_set_create(char* type); * Erase the contents of the set and free allocated memory. * * @param set The set to erase. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ void fossil_set_erase(fossil_set_t* set); @@ -54,6 +56,7 @@ void fossil_set_erase(fossil_set_t* set); * @param set The set to insert data into. * @param data The data to insert. * @return The error code indicating the success or failure of the operation. + * @note O(1) - Constant time complexity. */ int32_t fossil_set_insert(fossil_set_t* set, fossil_tofu_t data); @@ -63,6 +66,7 @@ int32_t fossil_set_insert(fossil_set_t* set, fossil_tofu_t data); * @param set The set to remove data from. * @param data The data to remove. * @return The error code indicating the success or failure of the operation. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ int32_t fossil_set_remove(fossil_set_t* set, fossil_tofu_t data); @@ -72,6 +76,7 @@ int32_t fossil_set_remove(fossil_set_t* set, fossil_tofu_t data); * @param set The set to search. * @param data The data to search for. * @return The error code indicating the success or failure of the operation. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ int32_t fossil_set_search(const fossil_set_t* set, fossil_tofu_t data); @@ -80,6 +85,7 @@ int32_t fossil_set_search(const fossil_set_t* set, fossil_tofu_t data); * * @param set The set for which to get the size. * @return The size of the set. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ size_t fossil_set_size(const fossil_set_t* set); @@ -89,6 +95,7 @@ size_t fossil_set_size(const fossil_set_t* set); * @param set The set from which to get the data. * @param data The data to search for. * @return A pointer to the matching data, or NULL if not found. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ fossil_tofu_t* fossil_set_getter(fossil_set_t* set, fossil_tofu_t data); @@ -98,6 +105,7 @@ fossil_tofu_t* fossil_set_getter(fossil_set_t* set, fossil_tofu_t data); * @param set The set in which to set the data. * @param data The data to set. * @return The error code indicating the success or failure of the operation. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ int32_t fossil_set_setter(fossil_set_t* set, fossil_tofu_t data); @@ -106,6 +114,7 @@ int32_t fossil_set_setter(fossil_set_t* set, fossil_tofu_t data); * * @param set The set to check. * @return True if the set is not empty, false otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_set_not_empty(const fossil_set_t* set); @@ -114,6 +123,7 @@ bool fossil_set_not_empty(const fossil_set_t* set); * * @param set The set to check. * @return True if the set is not a null pointer, false otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_set_not_cnullptr(const fossil_set_t* set); @@ -122,6 +132,7 @@ bool fossil_set_not_cnullptr(const fossil_set_t* set); * * @param set The set to check. * @return True if the set is empty, false otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_set_is_empty(const fossil_set_t* set); @@ -130,6 +141,7 @@ bool fossil_set_is_empty(const fossil_set_t* set); * * @param set The set to check. * @return True if the set is a null pointer, false otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_set_is_cnullptr(const fossil_set_t* set); @@ -139,6 +151,7 @@ bool fossil_set_is_cnullptr(const fossil_set_t* set); * @param set The set to check. * @param data The data to search for. * @return True if the set contains the element, false otherwise. + * @note O(n) - Linear time complexity, where n is the number of elements in the set. */ int32_t fossil_set_contains(const fossil_set_t* set, fossil_tofu_t data); diff --git a/code/logic/fossil/tofu/stack.h b/code/logic/fossil/tofu/stack.h index a01a40b..252a021 100644 --- a/code/logic/fossil/tofu/stack.h +++ b/code/logic/fossil/tofu/stack.h @@ -37,6 +37,7 @@ typedef struct fossil_stack_t { * * @param list_type The type of data the stack will store. * @return The created stack. + * @note Time complexity: O(1) */ fossil_stack_t* fossil_stack_create(char* type); @@ -44,6 +45,7 @@ fossil_stack_t* fossil_stack_create(char* type); * Erase the contents of the stack and free allocated memory. * * @param stack The stack to erase. + * @note Time complexity: O(n) */ void fossil_stack_erase(fossil_stack_t* stack); @@ -53,6 +55,7 @@ void fossil_stack_erase(fossil_stack_t* stack); * @param stack The stack to insert data into. * @param data The data to insert. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_stack_insert(fossil_stack_t* stack, fossil_tofu_t data); @@ -62,6 +65,7 @@ int32_t fossil_stack_insert(fossil_stack_t* stack, fossil_tofu_t data); * @param stack The stack to remove data from. * @param[out] data A pointer to store the removed data. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(1) */ int32_t fossil_stack_remove(fossil_stack_t* stack, fossil_tofu_t* data); @@ -71,6 +75,7 @@ int32_t fossil_stack_remove(fossil_stack_t* stack, fossil_tofu_t* data); * @param stack The stack to search. * @param data The data to search for. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_stack_search(const fossil_stack_t* stack, fossil_tofu_t data); @@ -79,6 +84,7 @@ int32_t fossil_stack_search(const fossil_stack_t* stack, fossil_tofu_t data); * * @param stack The stack for which to get the size. * @return The size of the stack. + * @note Time complexity: O(n) */ size_t fossil_stack_size(const fossil_stack_t* stack); @@ -88,6 +94,7 @@ size_t fossil_stack_size(const fossil_stack_t* stack); * @param stack The stack from which to get the data. * @param data The data to search for. * @return A pointer to the matching data, or NULL if not found. + * @note Time complexity: O(n) */ fossil_tofu_t* fossil_stack_getter(fossil_stack_t* stack, fossil_tofu_t data); @@ -97,6 +104,7 @@ fossil_tofu_t* fossil_stack_getter(fossil_stack_t* stack, fossil_tofu_t data); * @param stack The stack in which to set the data. * @param data The data to set. * @return The error code indicating the success or failure of the operation. + * @note Time complexity: O(n) */ int32_t fossil_stack_setter(fossil_stack_t* stack, fossil_tofu_t data); @@ -105,6 +113,7 @@ int32_t fossil_stack_setter(fossil_stack_t* stack, fossil_tofu_t data); * * @param stack The stack to check. * @return True if the stack is not empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_stack_not_empty(const fossil_stack_t* stack); @@ -113,6 +122,7 @@ bool fossil_stack_not_empty(const fossil_stack_t* stack); * * @param stack The stack to check. * @return True if the stack is not a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_stack_not_cnullptr(const fossil_stack_t* stack); @@ -121,6 +131,7 @@ bool fossil_stack_not_cnullptr(const fossil_stack_t* stack); * * @param stack The stack to check. * @return True if the stack is empty, false otherwise. + * @note Time complexity: O(1) */ bool fossil_stack_is_empty(const fossil_stack_t* stack); @@ -129,6 +140,7 @@ bool fossil_stack_is_empty(const fossil_stack_t* stack); * * @param stack The stack to check. * @return True if the stack is a null pointer, false otherwise. + * @note Time complexity: O(1) */ bool fossil_stack_is_cnullptr(const fossil_stack_t* stack); @@ -138,6 +150,7 @@ bool fossil_stack_is_cnullptr(const fossil_stack_t* stack); * @param stack The stack to get the top element from. * @param default_value The default value to return if the stack is empty. * @return The top element of the stack or the default value if the stack is empty. + * @note Time complexity: O(1) */ fossil_tofu_t fossil_stack_top(fossil_stack_t* stack, fossil_tofu_t default_value); diff --git a/code/logic/fossil/tofu/tofu.h b/code/logic/fossil/tofu/tofu.h index 8b679c0..36f6e37 100644 --- a/code/logic/fossil/tofu/tofu.h +++ b/code/logic/fossil/tofu/tofu.h @@ -131,6 +131,7 @@ typedef void * tofu_memory_t; * @param type The type string. * @param value The value string. * @return The created `fossil_tofu_t` object. + * @note O(1) - Constant time complexity. */ fossil_tofu_t fossil_tofu_create(char* type, char* value); @@ -138,6 +139,7 @@ fossil_tofu_t fossil_tofu_create(char* type, char* value); * Memorization (caching) function for a `fossil_tofu_t` object. * * @param tofu The `fossil_tofu_t` object to be memorized. + * @note O(1) - Constant time complexity. */ void fossil_tofu_memorize(fossil_tofu_t *tofu); @@ -145,6 +147,7 @@ void fossil_tofu_memorize(fossil_tofu_t *tofu); * Utility function to print a `fossil_tofu_t` object. * * @param tofu The `fossil_tofu_t` object to be printed. + * @note O(1) - Constant time complexity. */ void fossil_tofu_print(fossil_tofu_t tofu); @@ -152,6 +155,7 @@ void fossil_tofu_print(fossil_tofu_t tofu); * Function to destroy a `fossil_tofu_t` object and free the allocated memory. * * @param tofu The `fossil_tofu_t` object to be destroyed. + * @note O(1) - Constant time complexity. */ void fossil_tofu_erase(fossil_tofu_t *tofu); @@ -160,6 +164,7 @@ void fossil_tofu_erase(fossil_tofu_t *tofu); * * @param type The type string to be checked. * @return `true` if the type is valid, `false` otherwise. + * @note O(n) - Linear time complexity, where n is the number of valid types. */ bool fossil_tofu_is_valid_type(const char *type); @@ -168,6 +173,7 @@ bool fossil_tofu_is_valid_type(const char *type); * * @param type The `fossil_tofu_t` object's type. * @return The string representation of the type. + * @note O(1) - Constant time complexity. */ const char* fossil_tofu_type_to_string(fossil_tofu_type_t type); @@ -177,6 +183,7 @@ const char* fossil_tofu_type_to_string(fossil_tofu_type_t type); * @param tofu1 The first `fossil_tofu_t` object. * @param tofu2 The second `fossil_tofu_t` object. * @return `true` if the objects are equal, `false` otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_tofu_equals(fossil_tofu_t tofu1, fossil_tofu_t tofu2); @@ -185,6 +192,7 @@ bool fossil_tofu_equals(fossil_tofu_t tofu1, fossil_tofu_t tofu2); * * @param tofu The `fossil_tofu_t` object to be copied. * @return The copied `fossil_tofu_t` object. + * @note O(1) - Constant time complexity. */ fossil_tofu_t fossil_tofu_copy(fossil_tofu_t tofu); @@ -194,6 +202,7 @@ fossil_tofu_t fossil_tofu_copy(fossil_tofu_t tofu); * @param tofu1 The first `fossil_tofu_t` object. * @param tofu2 The second `fossil_tofu_t` object. * @return `true` if the objects are equal, `false` otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_tofu_compare(fossil_tofu_t *tofu1, fossil_tofu_t *tofu2); @@ -203,6 +212,7 @@ bool fossil_tofu_compare(fossil_tofu_t *tofu1, fossil_tofu_t *tofu2); * @param array The array of elements to be transformed. * @param size The size of the array. * @param func The function to be applied to each element. + * @note O(n) - Linear time complexity, where n is the size of the array. */ void fossil_tofu_actionof_transform(fossil_tofu_t *array, size_t size, fossil_tofu_t (*func)(fossil_tofu_t)); @@ -214,6 +224,7 @@ void fossil_tofu_actionof_transform(fossil_tofu_t *array, size_t size, fossil_to * @param init The initial value for accumulation. * @param func The function to be applied to each element during accumulation. * @return The accumulated value. + * @note O(n) - Linear time complexity, where n is the size of the array. */ fossil_tofu_t fossil_tofu_actionof_accumulate(fossil_tofu_t *array, size_t size, fossil_tofu_t init, fossil_tofu_t (*func)(fossil_tofu_t, fossil_tofu_t)); @@ -224,6 +235,7 @@ fossil_tofu_t fossil_tofu_actionof_accumulate(fossil_tofu_t *array, size_t size, * @param size The size of the array. * @param pred The predicate function to determine whether an element should be included in the filtered result. * @return The number of elements that pass the filter. + * @note O(n) - Linear time complexity, where n is the size of the array. */ size_t fossil_tofu_actionof_filter(fossil_tofu_t *array, size_t size, bool (*pred)(fossil_tofu_t)); @@ -235,6 +247,7 @@ size_t fossil_tofu_actionof_filter(fossil_tofu_t *array, size_t size, bool (*pre * @param key The key to search for. * @param compare The comparison function to determine equality between elements. * @return A pointer to the first occurrence of the key in the array, or NULL if not found. + * @note O(n) - Linear time complexity, where n is the size of the array. */ fossil_tofu_t* fossil_tofu_actionof_search(fossil_tofu_t *array, size_t size, fossil_tofu_t key, bool (*compare)(fossil_tofu_t, fossil_tofu_t)); @@ -243,6 +256,7 @@ fossil_tofu_t* fossil_tofu_actionof_search(fossil_tofu_t *array, size_t size, fo * * @param array The array of elements to be reversed. * @param size The size of the array. + * @note O(n) - Linear time complexity, where n is the size of the array. */ void fossil_tofu_actionof_reverse(fossil_tofu_t *array, size_t size); @@ -252,6 +266,7 @@ void fossil_tofu_actionof_reverse(fossil_tofu_t *array, size_t size); * @param array The array containing the elements to be swapped. * @param index1 The index of the first element to be swapped. * @param index2 The index of the second element to be swapped. + * @note O(1) - Constant time complexity. */ void fossil_tofu_actionof_swap(fossil_tofu_t *array, size_t index1, size_t index2); @@ -261,6 +276,7 @@ void fossil_tofu_actionof_swap(fossil_tofu_t *array, size_t index1, size_t index * @param a The first element to be compared. * @param b The second element to be compared. * @return A negative value if a is less than b, a positive value if a is greater than b, or zero if they are equal. + * @note O(1) - Constant time complexity. */ int fossil_tofu_actionof_compare(fossil_tofu_t a, fossil_tofu_t b); @@ -271,6 +287,7 @@ int fossil_tofu_actionof_compare(fossil_tofu_t a, fossil_tofu_t b); * @param size The size of the array. * @param func The function to be applied to each pair of elements during reduction. * @return The reduced value. + * @note O(n) - Linear time complexity, where n is the size of the array. */ fossil_tofu_t fossil_tofu_actionof_reduce(fossil_tofu_t *array, size_t size, fossil_tofu_t (*func)(fossil_tofu_t, fossil_tofu_t)); @@ -279,6 +296,7 @@ fossil_tofu_t fossil_tofu_actionof_reduce(fossil_tofu_t *array, size_t size, fos * * @param array The array of elements to be shuffled. * @param size The size of the array. + * @note O(n) - Linear time complexity, where n is the size of the array. */ void fossil_tofu_actionof_shuffle(fossil_tofu_t *array, size_t size); @@ -288,6 +306,7 @@ void fossil_tofu_actionof_shuffle(fossil_tofu_t *array, size_t size); * @param array The array of elements to apply the function to. * @param size The size of the array. * @param func The function to be applied to each element. + * @note O(n) - Linear time complexity, where n is the size of the array. */ void fossil_tofu_actionof_for_each(fossil_tofu_t *array, size_t size, void (*func)(fossil_tofu_t)); @@ -298,6 +317,7 @@ void fossil_tofu_actionof_for_each(fossil_tofu_t *array, size_t size, void (*fun * @param size The size of the array. * @param pred The predicate function to determine the partitioning condition. * @return The index of the first element in the second partition. + * @note O(n) - Linear time complexity, where n is the size of the array. */ size_t fossil_tofu_actionof_partition(fossil_tofu_t *array, size_t size, bool (*pred)(fossil_tofu_t)); @@ -308,6 +328,7 @@ size_t fossil_tofu_actionof_partition(fossil_tofu_t *array, size_t size, bool (* * @param size The size of the array. * @param func The function to be applied to each pair of elements during calculation. * @return The calculated summary. + * @note O(n) - Linear time complexity, where n is the size of the array. */ fossil_tofu_t fossil_tofu_actionof_summary(fossil_tofu_t *array, size_t size, fossil_tofu_t (*func)(fossil_tofu_t, fossil_tofu_t)); @@ -317,6 +338,7 @@ fossil_tofu_t fossil_tofu_actionof_summary(fossil_tofu_t *array, size_t size, fo * @param array The array of elements to calculate the average for. * @param size The size of the array. * @return The calculated average. + * @note O(n) - Linear time complexity, where n is the size of the array. */ fossil_tofu_t fossil_tofu_actionof_average(fossil_tofu_t *array, size_t size); @@ -328,6 +350,7 @@ fossil_tofu_t fossil_tofu_actionof_average(fossil_tofu_t *array, size_t size); * @param array The array of tofu. * @param size The size of the array. * @return The created iterator. + * @note O(1) - Constant time complexity. */ fossil_tofu_iteratorof_t fossil_tofu_iteratorof_create(fossil_tofu_t *array, size_t size); @@ -338,6 +361,7 @@ fossil_tofu_iteratorof_t fossil_tofu_iteratorof_create(fossil_tofu_t *array, siz * * @param iterator The iterator to check. * @return true if the iterator has more elements, false otherwise. + * @note O(1) - Constant time complexity. */ bool fossil_tofu_iteratorof_has_next(fossil_tofu_iteratorof_t *iterator); @@ -348,6 +372,7 @@ bool fossil_tofu_iteratorof_has_next(fossil_tofu_iteratorof_t *iterator); * * @param iterator The iterator. * @return The next element in the iterator. + * @note O(1) - Constant time complexity. */ fossil_tofu_t fossil_tofu_iteratorof_next(fossil_tofu_iteratorof_t *iterator); @@ -357,6 +382,7 @@ fossil_tofu_t fossil_tofu_iteratorof_next(fossil_tofu_iteratorof_t *iterator); * This function resets the iterator to the beginning, allowing iteration from the start again. * * @param iterator The iterator to reset. + * @note O(1) - Constant time complexity. */ void fossil_tofu_iteratorof_reset(fossil_tofu_iteratorof_t *iterator); @@ -365,6 +391,7 @@ void fossil_tofu_iteratorof_reset(fossil_tofu_iteratorof_t *iterator); * * @param size Size of the memory to allocate. * @return Pointer to the allocated memory. + * @note O(1) - Constant time complexity. */ tofu_memory_t fossil_tofu_alloc(size_t size); @@ -374,6 +401,7 @@ tofu_memory_t fossil_tofu_alloc(size_t size); * @param ptr Pointer to the memory to reallocate. * @param size Size of the memory to reallocate. * @return Pointer to the reallocated memory. + * @note O(1) - Constant time complexity. */ tofu_memory_t fossil_tofu_realloc(tofu_memory_t ptr, size_t size); @@ -381,6 +409,7 @@ tofu_memory_t fossil_tofu_realloc(tofu_memory_t ptr, size_t size); * @brief Free memory. * * @param ptr Pointer to the memory to free. + * @note O(1) - Constant time complexity. */ void fossil_tofu_free(tofu_memory_t ptr); @@ -389,6 +418,7 @@ void fossil_tofu_free(tofu_memory_t ptr); * * @param str String to duplicate. * @return Pointer to the duplicated string. + * @note O(n) - Linear time complexity, where n is the length of the string. */ char* fossil_tofu_strdup(const char* str); diff --git a/code/logic/fossil/tofu/vector.h b/code/logic/fossil/tofu/vector.h index a995e36..54518d3 100644 --- a/code/logic/fossil/tofu/vector.h +++ b/code/logic/fossil/tofu/vector.h @@ -32,6 +32,8 @@ typedef struct { /** * Create a new vector with the specified expected type. + * + * Time complexity: O(1) * * @param expected_type The expected type of elements in the vector. * @return The created vector. @@ -40,6 +42,8 @@ fossil_vector_t* fossil_vector_create(char* type); /** * Erase the contents of the vector and free allocated memory. + * + * Time complexity: O(n) * * @param vector The vector to erase. */ @@ -47,6 +51,8 @@ void fossil_vector_erase(fossil_vector_t* vector); /** * Add an element to the end of the vector. + * + * Amortized time complexity: O(1) * * @param vector The vector to which the element will be added. * @param element The element to add. @@ -55,6 +61,8 @@ void fossil_vector_push_back(fossil_vector_t* vector, fossil_tofu_t element); /** * Search for a target element in the vector. + * + * Time complexity: O(n) * * @param vector The vector to search. * @param target The element to search for. @@ -64,6 +72,8 @@ int fossil_vector_search(const fossil_vector_t* vector, fossil_tofu_t target); /** * Reverse the order of elements in the vector. + * + * Time complexity: O(n) * * @param vector The vector to reverse. */ @@ -71,6 +81,8 @@ void fossil_vector_reverse(fossil_vector_t* vector); /** * Check if the vector is a null pointer. + * + * Time complexity: O(1) * * @param vector The vector to check. * @return True if the vector is a null pointer, false otherwise. @@ -79,6 +91,8 @@ bool fossil_vector_is_cnullptr(const fossil_vector_t* vector); /** * Check if the vector is not a null pointer. + * + * Time complexity: O(1) * * @param vector The vector to check. * @return True if the vector is not a null pointer, false otherwise. @@ -87,6 +101,8 @@ bool fossil_vector_not_cnullptr(const fossil_vector_t* vector); /** * Check if the vector is empty. + * + * Time complexity: O(1) * * @param vector The vector to check. * @return True if the vector is empty, false otherwise. @@ -95,6 +111,8 @@ bool fossil_vector_is_empty(const fossil_vector_t* vector); /** * Check if the vector is not empty. + * + * Time complexity: O(1) * * @param vector The vector to check. * @return True if the vector is not empty, false otherwise. @@ -103,6 +121,8 @@ bool fossil_vector_not_empty(const fossil_vector_t* vector); /** * Set the element at the specified index in the vector. + * + * Time complexity: O(1) * * @param vector The vector in which to set the element. * @param index The index at which to set the element. @@ -112,6 +132,8 @@ void fossil_vector_setter(fossil_vector_t* vector, size_t index, fossil_tofu_t e /** * Get the element at the specified index in the vector. + * + * Time complexity: O(1) * * @param vector The vector from which to get the element. * @param index The index from which to get the element. @@ -121,6 +143,8 @@ fossil_tofu_t* fossil_vector_getter(const fossil_vector_t* vector, size_t index) /** * Get the size of the vector. + * + * Time complexity: O(1) * * @param vector The vector for which to get the size. * @return The size of the vector. @@ -129,6 +153,8 @@ size_t fossil_vector_size(const fossil_vector_t* vector); /** * Display the contents of the vector. + * + * Time complexity: O(n) * * @param vector The vector to peek into. */