/** @brief Splits a list into an even and an odd list * * @param list the List to be splitted (this list will retain de odd numbers) * @return the list containing the even numbers */ List *split_by_parity(List *list){ List *odd_list = new_empty_list(); List *even_list = new_empty_list(); while(is_empty(list) != 1){ if(list->first->content % 2 != 0){ append_cell(odd_list, remove_by_idx(list, 0)); } else { append_cell(even_list, remove_by_idx(list, 0)); } } list->first = even_list->first; free(even_list); return odd_list; }
/** @brief Sorts a list using the bubble sort technique * * @param list the list to be sorted */ void sort(List *list){ List *n_list = new_empty_list(); while(is_empty(list) != 1){ append(n_list, remove_by_idx(list,get_min(list))->content); } merge_lists(list, n_list); }
void dsp_chunk_list::remove_bad_chunks() { bool blah = false; t_size idx; for(idx=0;idx<get_count();) { audio_chunk * chunk = get_item(idx); if (!chunk->is_valid()) { chunk->reset(); remove_by_idx(idx); blah = true; } else idx++; } if (blah) console::info("one or more bad chunks removed from dsp chunk list"); }
void metadb_handle_list::delete_by_idx(int idx) { metadb_handle * ptr = remove_by_idx(idx); if (ptr) ptr->handle_release(); }