/** * Removes and outputs the last returned element pair by <code>deque_zip_iter_next() * </code> without invalidating the iterator. * * @param[in] iter Iterator on which this operation is being performed * @param[out] out1 Output of the removed element from the first deque * @param[out] out2 Output of the removed element from the second deque * * @return CC_OK if the element was successfully removed, or CC_ERR_OUT_OF_RANGE. */ enum cc_stat deque_zip_iter_remove(DequeZipIter *iter, void **out1, void **out2) { if ((iter->index - 1) >= iter->d1->size || (iter->index - 1) >= iter->d2->size) return CC_ERR_OUT_OF_RANGE; deque_remove_at(iter->d1, iter->index - 1, out1); deque_remove_at(iter->d2, iter->index - 1, out2); iter->index--; return CC_OK; }
/** * Removes and returns the last returned element by <code>deque_iter_next() * </code> without invalidating the iterator. * * @param[in] iter the iterator on which this operation is being perfrormed * * @return the removed element */ void *deque_iter_remove(DequeIter *iter) { void *rm = deque_remove_at(iter->deque, iter->index); if (rm != NULL) iter->index--; return rm; }
/** * Removes and returns the specified element from the deque if such element * exists. In case the element doesn't exist NULL is retruned. NULL may also * be returned if the specified element is NULL. In this case calling <code> * deque_contains()</code> before this function can resolve the ambiguity. * * @param[in] deque the deque from which the element is being removed * @param[in] element the element being removed * * @return removed element, or NULL if the operation fails */ void *deque_remove(Deque *deque, void *element) { size_t index = deque_index_of(deque, element); if (index == NO_SUCH_INDEX) return NULL; return deque_remove_at(deque, index); }
/** * Removes the specified element from the deque if such element exists and * optionally sets the out parameter to the value of the removed element. * * @param[in] deque the deque from which the element is being removed * @param[in] element the element being removed * @param[out] out Pointer to where the removed value is stored, or NULL * if it is to be ignored * * @return CC_OK if the element was successfully removed, or * CC_ERR_VALUE_NOT_FOUND if the element was not found. */ enum cc_stat deque_remove(Deque *deque, void *element, void **out) { size_t index; enum cc_stat status = deque_index_of(deque, element, &index); if (status != CC_OK) return status; return deque_remove_at(deque, index, out); }
/** * Removes the last returned element by <code>deque_iter_next()</code> * function without invalidating the iterator and optionally sets the out * parameter to the value of the removed element. * * @note This function should only ever be called after a call to <code> * deque_iter_next()</code> * @param[out] out Pointer to where the removed element is stored, or NULL * if it is to be ignored * @param[in] iter the iterator on which this operation is being performed * * @return CC_OK if the element was successfully removed, or * CC_ERR_VALUE_NOT_FOUND. */ enum cc_stat deque_iter_remove(DequeIter *iter, void **out) { void *rm; enum cc_stat status = deque_remove_at(iter->deque, iter->index, &rm); if (status == CC_OK) { iter->index--; if (out) *out = rm; } return status; }