All Projects → maksimandrianov → Cdcontainers

maksimandrianov / Cdcontainers

Licence: mit
Library of data containers and data structures for C programming language.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Cdcontainers

Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (+119.3%)
Mutual labels:  stack, datastructures, collections, avl-tree, queue, map, containers
C Macro Collections
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Stars: ✭ 192 (+236.84%)
Mutual labels:  stack, datastructures, heap, library, queue, containers
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (+182.46%)
Mutual labels:  stack, collections, heap, library, queue
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+1878.95%)
Mutual labels:  stack, collections, queue, map
Algorithms
Data Structures & Algorithms. Includes solutions for Cracking the Coding Interview 6th Edition
Stars: ✭ 89 (+56.14%)
Mutual labels:  stack, queue, datastructures, heap
Cdsa
A library of generic intrusive data structures and algorithms in ANSI C
Stars: ✭ 549 (+863.16%)
Mutual labels:  stack, datastructures, collections, queue
DSA
Data Structures and Algorithms
Stars: ✭ 13 (-77.19%)
Mutual labels:  avl-tree, queue, datastructures, heap
Staticvec
Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.
Stars: ✭ 236 (+314.04%)
Mutual labels:  stack, datastructures, collections, containers
Libgenerics
libgenerics is a minimalistic and generic library for C basic data structures.
Stars: ✭ 42 (-26.32%)
Mutual labels:  stack, library, queue, map
Coding Interview Gym
leetcode.com , algoexpert.io solutions in python and swift
Stars: ✭ 451 (+691.23%)
Mutual labels:  stack, heap, queue
Qlibc
qLibc is a simple and yet powerful C library providing generic data structures and algorithms
Stars: ✭ 614 (+977.19%)
Mutual labels:  stack, library, queue
Learningmasteringalgorithms C
Mastering Algorithms with C 《算法精解:C语言描述》源码及Xcode工程、Linux工程
Stars: ✭ 615 (+978.95%)
Mutual labels:  stack, heap, queue
Android interviews
🚀Everything you need to know to find a android job. 算法 / 面试题 / Android 知识点 🔥🔥🔥 总结不易,你的 star 是我最大的动力!
Stars: ✭ 510 (+794.74%)
Mutual labels:  stack, heap, queue
needle
📌📚 An extensive standalone data structure library for JavaScript.
Stars: ✭ 25 (-56.14%)
Mutual labels:  stack, queue, heap
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+7691.23%)
Mutual labels:  stack, heap, queue
Algorithm-Data-Structures-Python
Various useful data structures in Python
Stars: ✭ 34 (-40.35%)
Mutual labels:  stack, queue, heap
Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+714.04%)
Mutual labels:  stack, queue, heap
DEPRECATED-data-structures
A collection of powerful data structures
Stars: ✭ 2,648 (+4545.61%)
Mutual labels:  stack, queue, heap
Iruka
A collection of classical data structures ⛩ and algorithms 🏃‍♂️ implemented in Typescript with video lectures 📹.
Stars: ✭ 625 (+996.49%)
Mutual labels:  stack, avl-tree, queue
Data-structures
Data Structures in Java
Stars: ✭ 13 (-77.19%)
Mutual labels:  stack, queue, datastructures

cdcontainers - data containers and data structures for C

Build Status Documentation Benchmarks

Library of data containers and data structures for C programming language. The cdcontainers interface is similar to C ++ STL. The library contains the following data containers:

  • cdc_array - dynamic array
  • cdc_list - doubly linked list
  • cdc_circular_array - circular array
  • cdc_heap - binary heap
  • cdc_binomial_heap - binomial heap
  • cdc_pairing_heap - pairing heap
  • cdc_hash_table - hash table with collisions resolved by chaining
  • cdc_avl_tree - avl tree
  • cdc_splay_tree - splay tree
  • cdc_treap - сartesian tree

and following adapters:

  • cdc_deque (Can work with: cdc_array, cdc_list, cdc_circular_array)
  • cdc_stack (Can work with: cdc_array, cdc_list, cdc_circular_array)
  • cdc_queue (Can work with: cdc_array, cdc_list, cdc_circular_array)
  • cdc_priority_queue (Can work with: cdc_heap, cdc_binomial_heap, cdc_pairing_heap)
  • cdc_map (Can work with: cdc_avl_tree, cdc_splay_tree, cdc_treap, cdc_hash_table)

Example:

#define CDC_USE_SHORT_NAMES  // for short names (functions and structs without prefix cdc_*)
#include <cdcontainers/cdc.h>
#include <stdio.h>

int main(int argc, char** argv)
{
    array_t *array = NULL;

    if (array_ctor(&array, NULL) != CDC_STATUS_OK)
        /* error handling */;

    if (array_push_back(array, CDC_FROM_INT(8)) != CDC_STATUS_OK)
        /* error handling */;

    if (array_push_back(array, CDC_FROM_INT(2)) != CDC_STATUS_OK)
        /* error handling */;

    for (sizr_t i = 0; i < array_size(array); ++i)
        printf("%i\n", CDC_TO_INT(vector_get(v, i)));
        
    array_dtor(array);
}

Installation - Unix

To build and install cdcontainers from source, the following tools are needed:

  • make
  • cmake
  • gcc (or your other favorite compiler with minimal support ISO/IEC 9899:1999 (C99) standard)
  • cunit (for testing)

On Ubuntu or Debian, you can install them with:

$  sudo apt-get install cmake gcc make libcunit1-dev

To build and install cdstructures, do the following steps:

$ git clone https://github.com/maksimandrianov/cdcontainers
$ cd cdcontainers
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install

Hint on install location

By default, the package will be installed to /usr/local. However, on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. You can add it, but it may be easier to just install to /usr instead. To do this, invoke cmake as follows:

$ cmake -DCMAKE_INSTALL_PREFIX=/usr ..

Testing

To build and run tests, do the following steps:

$ make tests
$ make check

Usage

You can find examples in the directory examples.

To run the example, compile and link against the cdcontainers library (libcdcontainers.a/.so). If you followed the build steps above, this library will be under the build directory you created.

# Example on linux after running the build steps above. Assumes the
# `cdcontainers` and `build` directories are under the current directory.
$ gcc examples/map.c -isystem include -Llib -lcdcontainers -o map
./map

The output of this program is the following:

Phone book:
Elliott Mooney - (945) 616-4482
Laiba Juarez - (303) 885-5692
Lilia Friedman - (892) 670-4739
Tariq Beltran - (489) 600-7575
Phone book after adding Zak Byers:
Elliott Mooney - (945) 616-4482
Laiba Juarez - (303) 885-5692
Lilia Friedman - (892) 670-4739
Tariq Beltran - (489) 600-7575
Zak Byers - (551) 396-1880
Phone book after erasing Tariq Beltran:
Elliott Mooney - (945) 616-4482
Laiba Juarez - (303) 885-5692
Lilia Friedman - (892) 670-4739
Zak Byers - (551) 396-1880
Phone book after update phone of Zak Byers:
Elliott Mooney - (945) 616-4482
Laiba Juarez - (303) 885-5692
Lilia Friedman - (892) 670-4739
Zak Byers - (555) 396-188
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].