Git Product home page Git Product logo

lists.c's Introduction

lists.c

Latest release version

Different kinds of lists and list-like structures, implemented in pure C (ie. using pretty much only macros).

Currently implemented

  • Linked Lists (linkedlist.h): comes in two flavors, a value-based one (LL(type)) and a pointer-based one (LL_PTR(type)); does not feature cyclicity verification!
  • Vector (vec.h): scalable arrays
  • Ring (ring.h): scalable circular arrays
  • Binary trees (btree.h): does not feature cyclicity verification!
  • Binary search trees (bstree.h)

Installation

The included build files make use of cmake.

You are very much going to have this repository as a depency of your program. If you aren't using git for said program already, then simply create a directory called dependencies and run git clone https://github.com/adri326/lists.c dependencies/lists.

Otherwise, you may run the following set of commands:

mkdir dependencies # if this hasn't been done already
git submodule add https://github.com/adri326/lists.c dependencies/lists
# Don't forget to run `git commit`!

Once that is done, head to your CMakeLists.txt file and include this library:

include(dependencies/lists/include.cmake)
target_link_libraries(YOUR_PROJECT PUBLIC lists-c)
target_include_directories(YOUR_PROJECT PUBLIC ${LISTS_C_INCLUDE_DIR})

You may now include this file in your source code:

#include <linkedlist.h>

DECL_LL(int); // declare the structure (put this in your .h if you're using this structure as a return value or argument or if you are using the structure across files)
DEF_LL(int); // fill in the body of the different linked list-related functions
DEF_LL_PRINTF(int, "%d"); // make the int_ll_printf function available

int main() {
  LL(int)* int_list = int_ll_new(0); // create a new linked list containing [0]
  int_list = int_ll_push_head(1); // append 1 to the list
  int_ll_printf(int_list); // print the list ([1, 0])
  int_ll_free(int_list); // free the list
}

Testing

You will need check installed on your system and have CMake be able to find it.

Clone this repository:

git clone https://github.com/adri326/lists.c lists
cd lists

Then build it:

mkdir build
cd build
cmake .. && make

And finally, you may run the tests:

./lists-test

lists.c's People

Contributors

adri326 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.