예제 #1
0
파일: lists.c 프로젝트: luizsol/MAC0122
/** @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;
}
예제 #2
0
파일: lists.c 프로젝트: luizsol/MAC0122
/** @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);
}
예제 #3
0
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");
}
예제 #4
0
void metadb_handle_list::delete_by_idx(int idx)
{
	metadb_handle * ptr = remove_by_idx(idx);
	if (ptr) ptr->handle_release();
}