示例#1
0
文件: 0000-main.c 项目: stillcold/src
int main(void){

    init_heap_and_dp();

#ifdef DEBUG_MODE
    print_heap(HEAP_MAX_LENGTH);
#endif

    /* Heap sort */
    mark_start();
    heap_sort(HEAP_MAX_LENGTH);
    mark_stop();
    get_time_difference(&time_count);

    printf("Time taken by heap sort: %d\n",(int)time_count.tv_usec);

#ifdef DEBUG_MODE
    print_heap(HEAP_MAX_LENGTH);
#endif

#ifdef DEBUG_MODE
    printf("Sort with bitmap.\n");
#endif

    /* Bitmap sort algorithm */
    mark_start();
    for (i = 1; i < HEAP_MAX_LENGTH; i++){
        set_bit_in_map((unsigned)array[i]);
    }
    mark_stop();
    get_time_difference(&time_count);

    printf("Time taken by bitmap sort: %d\n",(int)time_count.tv_usec);

#ifdef DEBUG_MODE
    show_bitmap();
    for (i = 1; i < MAP_MAX_LENGTH; i++){
        if (check_bit_in_map(i)){
            printf("%u\t", i);
        }
    }
    printf("\n");
#endif

    /* Algorithm: dp */
    printf("This is dp result: %d\n", dp_demo(5));

    /* Algorithm: BP(artificial network) */
    test_aritificial_neural_network();

    /* Algorithm: manacher */
    test_manacher();

    return 0;
}
示例#2
0
si_t engine_draw_bitmap(si_t graphics_device_handle, char* path, si_t align)
{
	struct bitmap bm;
    struct rectangle area;
    struct graphics_device * gd;

    gd = (struct graphics_device *)graphics_device_handle;
    area = gd->rectangle;

	bm.path = path;

	if(bitmap_init(&bm) == -1)
        return -1;

    bitmap_align(&bm, &area, align);

	show_bitmap(&bm, gd, &area);

	bitmap_exit(&bm);

    return 0;
}