GithubHelp home page GithubHelp logo

thepotatochronicler / listmv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from s-mv/listmv

0.0 0.0 0.0 23 KB

Library for dynamic lists and dictionaries in C.

License: MIT License

C 90.31% Makefile 9.69%

listmv's Introduction

listmv

A library that adds list/dictionary support to your C program.

Contents

Example code

Lists:

#include <stdio.h>
#include <listmv.h>

int main() {
    listmv name = new_listmv(char);

    listmv_push_array(&name, "smv\n", 5);

    printf("char at 2 %c\n", listmv_i(&name, 2)); // v
    // in theory this only works with char lists
    printf("Hello, %s\n", listmv_str_unwrap(name));

    listmv_free(name); // if the GC is on this is taken care of

    return 0;
}

Dicts (majorly TODO): This is how dictionaries could be used once I implement them:

#include <stdio.h>
#include <listmv.h>

int main() {
    dictmv dict = new_dictmv(int, float);
    dictmv_push(dict, 420, 6.9);
    dictmv_push(dict, 122, 8.5);
    float CGPA = dictmv_get_key_for(dict, 420); // 6.9
    int ID = dictmv_get_value_for(dict, 3.5);   // 133

    dictmv_free(dict); // if the GC is on this is taken care of
}

To use the GC just use the start_gc() function. Note that there's no stop_gc for a reason.

Build and Install

The GC and part of dictmv is still a work in progress. However you can still build using

make build

to generate headers and object at ./lib

Or install globally (Linux only) using

make install

to use it in any of your projects.

Notes

Work in progress.

TODO:

  • dictmv functionality

listmv's People

Contributors

s-mv avatar thepotatochronicler 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.