Giter Site home page Giter Site logo

blib's Introduction

Blib

About

Base Library (or Blib) is a collection of basic functions and datastructure implementations.

Usage

Dynamic arrays
#include <blib/datastructures/arrays/dynamic.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    dynamic_arr* arr = dynamic_arr_new(int);

    /* Append the elements */
    int elem = 1;
    dynamic_arr_append(arr, &elem);
    elem = 3;
    dynamic_arr_append(arr, &elem);
    elem = 2;
    dynamic_arr_insert_at(arr, 1, &elem);
    /* ------------------- */

    /* retrieve three elements */
    int elems[3] = {0};
    dynamic_arr_bulk_peek(arr, 0, elems, 2);
    /* ----------------------- */

    /* print elements */
    printf(
        "elems[0] = %i; elems[1] = %i; elems[2] = %i\n", 
        elems[0], elems[1], elems[2]);
    /* -------------- */

    /* Pop last element */
    dynamic_arr_truncate(arr, NULL);
    /* ---------------- */

    dynamic_arr_cleanup(arr);

    return 0;
}
Testing
#include <blib/testing/time/time_tests.h>
#include <stdlib.h>

time_test testfunc(unsigned int index, void* data) {
    (void)data;

    time_test test = time_test_start(NULL);

    volatile unsigned char i = rand() & 255;

    time_test_end(&test);

    test.state = (i != 69 ? TEST_SUCCESS : TEST_FAILURE);

    return test;
}

int main(void) {
    time_testrun_template testrun = time_testrun_new(
                                    "Random test", 
                                    1024, testfunc, NULL, 
                                    TESTRUN_ENABLE_ALL);

    time_testrun_results results = time_testrun_run(&testrun);

    time_testrun_print(&results);

    return 0;
}    

blib's People

Contributors

0xfadead avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.