Skip to content

Commit

Permalink
Implement dsc_list_erase()
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-jones committed Apr 25, 2024
1 parent d58236c commit 06ea31e
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 94 deletions.
50 changes: 36 additions & 14 deletions include/dsc_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ bool dsc_list_deinit(DSCList list);

/* Capacity */

/**
* @brief Gets the size of the list.
*
* @param list The list to get the size of.
* @return The size of the list, or -1 if the list is NULL.
*/
int dsc_list_size(const DSCList list);

/**
* @brief Checks if the list is empty.
*
Expand All @@ -60,6 +52,14 @@ int dsc_list_size(const DSCList list);
*/
bool dsc_list_is_empty(const DSCList list);

/**
* @brief Gets the size of the list.
*
* @param list The list to get the size of.
* @return The size of the list, or -1 if the list is NULL.
*/
int dsc_list_size(const DSCList list);

/* Element access */

/**
Expand All @@ -69,15 +69,17 @@ bool dsc_list_is_empty(const DSCList list);
*
* @return The value of the front element, or -1 if the list is empty or NULL.
*/
int dsc_list_get_head(const DSCList list);
int dsc_list_front(const DSCList list);

/**
* @brief Retrieves the value of the last element in the list.
*
* @param list The list to get the last element from.
* @return The value of the last element, or -1 if the list is empty or NULL.
*/
int dsc_list_get_tail(const DSCList list);
int dsc_list_back(const DSCList list);

/* Modifiers */

/**
* @brief Inserts a value at the beginning of the list.
Expand All @@ -89,6 +91,15 @@ int dsc_list_get_tail(const DSCList list);
*/
bool dsc_list_push_front(DSCList list, int value);

/**
* @brief Removes the first node from the list.
*
* @param list The list to remove the first node from.
*
* @return The popped value, -1 on failure.
*/
int dsc_list_pop_front(DSCList list);

/**
* @brief Inserts a value at the end of the list.
*
Expand All @@ -99,6 +110,16 @@ bool dsc_list_push_front(DSCList list, int value);
*/
bool dsc_list_push_back(DSCList list, int value);


/**
* @brief Removes the last node from the list.
*
* @param list The list to remove the last node from.
*
* @return The popped value, or -1 on failure.
*/
int dsc_list_pop_back(DSCList list);

/**
* @brief Inserts a value at a specific position in the list.
*
Expand All @@ -111,13 +132,14 @@ bool dsc_list_push_back(DSCList list, int value);
bool dsc_list_insert(DSCList list, int value, int position);

/**
* @brief Removes the first node from the list.
* @brief Erases the element at the specified position.
*
* @param list The list to remove the first node from.
* @param list The list to erase the element from.
* @param position The position of the element to erase.
*
* @return The popped value, -1 on failure.
* @return true if the element was erased successfully, false otherwise.
*/
int dsc_list_pop_front(DSCList list);
bool dsc_list_erase(DSCList list, int position);

/**
* @brief Removes the first occurrence of a value from the list.
Expand Down
Loading

0 comments on commit 06ea31e

Please sign in to comment.