Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing info regarding o of n #7

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions code/logic/fossil/tofu/arrayof.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ 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, ...);

/**
* @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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -75,20 +80,23 @@ 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);

/**
* @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);

/**
* @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);

Expand Down
14 changes: 14 additions & 0 deletions code/logic/fossil/tofu/doublylist.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ 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);

/**
* 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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -74,20 +78,23 @@ 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);

/**
* 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);

/**
* 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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions code/logic/fossil/tofu/dqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ 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);

/**
* 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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
14 changes: 14 additions & 0 deletions code/logic/fossil/tofu/forwardlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ 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);

/**
* 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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -72,20 +76,23 @@ 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);

/**
* 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);

/**
* 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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
Loading