quicksort.h

Epic cinematic scores, sweeping orchestral movements, heroic themes, and stirring emotional peaks, adventure,

July 27th, 2024suno

歌词

#pragma once #ifndef ORDERING_DEFINED #define ORDERING_DEFINED typedef enum { Ordering_LessThan = -1, Ordering_Equal = 0, Ordering_GreaterThan = 1, } Ordering; void _null_write_cb(void* userdata, void* loc) { (void)userdata; (void)loc; return; } #endif typedef ptrdiff_t ssize_t; void quicksort_swap(void* write_cb_userdata, char* a, char* b, ssize_t elem_size, void (*write_cb)(void*, void*)) { for (ssize_t i = 0; i < elem_size; i++) { char tmp = a[i]; a[i] = b[i]; b[i] = tmp; } write_cb(write_cb_userdata, (void*)a); write_cb(write_cb_userdata, (void*)b); } ssize_t partition( void* write_cb_userdata, void* cmp_cb_userdata, void* elems_void, ssize_t elem_size, ssize_t low, ssize_t high, void (*write_cb)(void*, void*), Ordering (*cmp_cb)(void*, void*, void*) ) { char* elems = (char*)elems_void; char* pivot = elems+high*elem_size; //quicksort_swap(write_cb_userdata, pivot, elems+high*elem_size, elem_size, write_cb); ssize_t i = low-1; for(ssize_t j = low; j < high; j++) { char* a = elems+j*elem_size; if (cmp_cb(cmp_cb_userdata, a, pivot) <= 0) { i += 1; quicksort_swap(write_cb_userdata, elems + i*elem_size, elems+ j*elem_size, elem_size, write_cb); } } quicksort_swap(write_cb_userdata, elems +(i+1)*elem_size, elems +high*elem_size, elem_size, write_cb); return i+1; } #include <stdlib.h> #include <time.h> int partition_r( void* write_cb_userdata, void* cmp_cb_userdata, void* elems_void, ssize_t elem_size, ssize_t low, ssize_t high, void (*write_cb)(void*, void*), Ordering (*cmp_cb)(void*, void*, void*) ) { char* elems = (char*)elems_void; srand(time(NULL)); int random = low + rand() % (high - low); quicksort_swap(0, elems+random*elem_size, elems+high*elem_size, elem_size, _null_write_cb); return partition(write_cb_userdata, cmp_cb_userdata, elems_void, elem_size, low, high, write_cb, cmp_cb); } void quicksort_impl( void* write_cb_userdata, void* cmp_cb_userdata, void* elems, ssize_t elem_size, ssize_t elem_low, ssize_t elem_high, void (*write_cb)(void*, void*), Ordering (*cmp_cb)(void*, void*, void*) ) { if (elem_low < elem_high) { ssize_t index = partition_r(write_cb_userdata, cmp_cb_userdata, elems, elem_size, elem_low, elem_high, write_cb, cmp_cb); quicksort_impl(write_cb_userdata, cmp_cb_userdata, elems, elem_size, elem_low, index-1, write_cb, cmp_cb); quicksort_impl(write_cb_userdata, cmp_cb_userdata, elems, elem_size, index+1, elem_high, write_cb, cmp_cb); } } void quicksort( void* write_cb_userdata, void* cmp_cb_userdata, void* elems, size_t elem_size, size_t elem_len, void (*write_cb)(void*, void*), Ordering (*cmp_cb)(void*, void*, void*) ) { if (!write_cb) { write_cb=_null_write_cb; } quicksort_impl(wri

推荐歌曲

bryllup sang
bryllup sang

kjærlighet

Gibberish
Gibberish

Disstrack rap jazz opera piano horror quirky

Only Thing that matters
Only Thing that matters

sad, dark, mystic, powerful orchestral batman; rising tension

Under the Stars
Under the Stars

afro house melodic deep house

Dance Like Nobody's Watching
Dance Like Nobody's Watching

Club edm dubstep hip hop

Trail of Dreams (An Oregon story)
Trail of Dreams (An Oregon story)

Americana,folk, guitar, banjo, fiddle, and harmonica ,enhance the rustic and nostalgic, old record

竹林之約
竹林之約

Soft and emotional old-fashioned recorder, made of purple bamboo, in the key of G or F. Smooth playing.

切ない夜のメロディ
切ない夜のメロディ

J-POP,BPM128,Band style,Female Vocal,sad and emotional

浪漫小调
浪漫小调

爵士 带有爵士元素 快节奏

ВАХТЕРАМ_007
ВАХТЕРАМ_007

Ukrainian folk song, reggae, orchestral, epic, instrumental, metal

Eastern Symphony Groove
Eastern Symphony Groove

jazz,jazz fusion,ecm style jazz,folk,acoustic,meditative,ethio-jazz,hindustani classical,indian classical

ding-a-dong
ding-a-dong

Свист, тяжелый металл, электрогитара, саксофон, бас-гитара, мелодичный, Романтика, Хриплый мужской голос - Рок

Past Those Gray Skies
Past Those Gray Skies

Upbeat Emotional Pop

Racing Hearts
Racing Hearts

female vocalist,dance,pop,dance-pop,electropop,contemporary r&b,melodic,warm,energetic,english,kpop,emotional

Catchphrase Groove
Catchphrase Groove

instrumental,instrumental,instrumental,instrumental,dance-pop,dance,rhythmic,melodic,passionate,synth funk,hip hop,party,energetic,uplifting,nu-disco,summer,happy,playful

Blessed Union
Blessed Union

uplifting pop melodic

Candy Pink
Candy Pink

Intro with dubstep, female hardcore vocals, , hardcore shouting, low bass, insert soft piano verses with pure voice midd

Vivir la Vida
Vivir la Vida

rap punk pop electro