#include #include #include "vec.h" int compar(const void* lhs, const void* rhs) { return *(const int*)lhs - *(const int*)rhs; } int main(void) { int i, j, k; VEC_T(int) vec = VEC_0(int); srandom(time(NULL)); for (i = 0; i < 40; ++i) { j = random() % 10; k = VEC_BSRCHF(int, &vec, &j, compar); VEC_INS(int, &vec, k, &j, 1); } for (i = 0; i < VEC_LEN(int, &vec); ++i) { printf("%d", VEC_ELTS(int, &vec)[i]); } printf("\n"); for (i = 0; i < 10; ++i) { j = VEC_BSRCHF(int, &vec, &i, compar); k = VEC_BSRCHL(int, &vec, &i, compar); if (j == k) printf("%*d\n", j + 1, i); else printf("%*d%*d\n", j + 1, i, k - j, i); } return EXIT_SUCCESS; } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */