SortPlan_t * create_sort_plan(const Image * img, const Context_t * ctx) { if(ROW == get_orientation(ctx)) { return create_sort_plan(img, ctx, ROW); } else if(COLUMN == get_orientation(ctx)) { return create_sort_plan(img, ctx, COLUMN); } else { SortPlan_t * plan_ptr = create_sort_plan(img, ctx, ROW); plan_ptr->next_step_ptr = create_sort_plan(img, ctx, COLUMN); return plan_ptr; } }
void sort(struct Image * img, const Context_t * ctx) { // Create a list of sort plan steps SortPlan_t * plan_steps = create_sort_plan(img, ctx); for(const SortPlan_t * step = plan_steps; NULL != step; step = step->next_step_ptr) { Pixel_t * pixels = create_pixel_list(img, step); do_sort(pixels, step); sync_pixels(img, step, pixels); } destroy_sort_plan(plan_steps); }
void sort(struct image * img, const context_t * ctx) { sort_plan_t *plan_steps; if(ROW == ctx->orientation) { plan_steps = create_sort_plan(img, ctx, ROW); } else if(COLUMN == ctx->orientation) { plan_steps = create_sort_plan(img, ctx, COLUMN); } else { plan_steps = create_sort_plan(img, ctx, ROW); plan_steps->next_step_ptr = create_sort_plan(img, ctx, COLUMN); } for(const sort_plan_t * step = plan_steps; NULL != step; step = step->next_step_ptr) { pixel_t * pixels = create_pixel_list(img, step); do_sort(pixels, step); sync_pixels(img, step, pixels); } destroy_sort_plan(plan_steps); }