Multi-Purpose Header-Only C Data Structures

USAGE

These header files are meant to be a simple means of using datastructures in a C project. They are universally useable with any other C datatype and are well integrated with each other. All of the Header-Files Include DoxyGen Documentation which can and should be read before using them.

Values and Keys always get copied into the structures and not assigned! Changing the value of the pointer given to the structure later on wont affect the contents of the structure!

EXAMPLES

VOID ARRAY

#include <stdio.h>

#include "void_array.h"

int main() {
	struct void_array varray;
	varr_init(&varray, 10, sizeof(double), NULL);

	for (int i = 0; i < varray.capacity; i++) {
		double value = (i + 1) * 1.5;
		varr_add(&varray, &value);
	}


	printf("%f\n", varr_get(&varray, 6)); // 10.5

	// Values get pulled from the right at deletion
	varr_remove(&varray, 6);

	printf("%f\n", varr_get(&varray, 6)); // 12.0

	varr_free(&varray);

	return 0;
}

VOID DICT

#include <stdio.h>

#include "void_array.h"

int main() {
	struct void_dict vdict;
	vdict_init(&vdict, 25, sizeof(char) * 5, sizeof(double), NULL);


	double temp_c = 25.5;
	double rain_in_cm = 16;
	double uv_level = 3;

	vdict_add_pair(&vdict, "Temp", &temp_c);
	vdict_add_pair(&vdict, "Rain", &rain_in_cm);

	// The Keys must always be the given size. This could also be easily achived by creating an array.
	// const char uv_key[5] = "UV";
	// vdict_add_pair(&vdict, uv_key, &uv_level);
	vdict_add_pair(&vdict, "UV\0\0", &uv_level);


	printf("%f\n", vdict_get_value(&vdict, "Temp")); // 25.5

	vdict_free(&vdict);

	return 0;
}

COMBINATION

#include <stdio.h>

#include "void_array.h"
#include "void_dict.h"

int main() {
	struct void_dict vdict;
	vdict_init(&vdict, 10, sizeof(int), sizeof(struct void_array), varr_free);

	// i is 1 because keys can't be zero in a void dict
	for (int i = 1; i <= vdict.capacity; i++) {
		struct void_array sub_array;
		varr_init(&sub_array, 5, sizeof(double), NULL);
		for (int j = 0; j < varr.capacity; j++) {
			double value = (i + 1) * 1.5;
			varr_add(&sub_array, &value);
		}
		vdict_add_pair(&vdict, &i, &sub_array);

		// No Memory leakage because we told vdict how to free the non
		// standard values it contains (varr_free)
	}

	
	// Frees every value it contains and then itself
	vdict_free(&vdict);


	return 0;
}

LICENSE - MIT

See LICENSE file in the root directory of this repository

Owner
Andre Schneider
Junior Developer striving for greatness
Andre Schneider
Similar Resources

Wonderful library with lots of useful functions, algorithms and data structures in C, link it with -l9wada

Lib9wada Wonderful library with lots of useful functions, algorithms and data structures in C, link it with -l9wada Usage Compile the library with mak

Nov 21, 2022

Wonderful library with lots of useful functions, algorithms and data structures in C, link it with -l9wada

LibC+ Wonderful library with lots of useful functions, algorithms and data structures in C, link it with -lC+ Better than C, not as much as c++ Usage

Nov 21, 2022

A collection of basic data structures syntaxes, useful for competitive coding and placement exams

A collection of basic data structures syntaxes, useful for competitive coding and placement exams

Data-Structures A collection of basic data structures syntaxes, useful for competitive coding and placement exams 1. Array 2. Matrix 3. Linked List Si

Aug 8, 2021

The aim of this repository is to make it a one final stop for revision for technical interviews involving data structures and algorithms .

Hey 🙋‍♂️ This repository is meant for data structures and algorithms . I will be updating this often and will include all the data structures importa

Sep 29, 2022

This is a beginner-friendly project aiming to build a problem-set on different data structures and algorithms in different programming languages.

DSAready Overview This is a beginner-friendly project that aims to create a problem-set for various Data Structures and Algorithms. Being a programmer

Aug 17, 2022

Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design

Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design

Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.

Oct 4, 2022

Explore the world of Data Structures and Algorithm

Explore the world of Data Structures and Algorithm

Hey Everyone! 👋 DSA- PlayYard is the first open source project of Lets Grow More Community. It is the perfect place to start with or to test your DSA

Oct 9, 2022

Postmodern immutable and persistent data structures for C++ — value semantics at scale

Postmodern immutable and persistent data structures for C++ — value semantics at scale

immer is a library of persistent and immutable data structures written in C++. These enable whole new kinds of architectures for interactive and concu

Nov 23, 2022
Step is a C++17, header-only library of STL-like algorithms and data structures
Step is a C++17, header-only library of STL-like algorithms and data structures

Step is a C++17, header-only library of STL-like algorithms and data structures. Installation git clone --depth 1 https://github.com/storm-ptr/step.gi

Sep 1, 2022
Multi-Scale Geometric Consistency Guided and Planar Prior Assisted Multi-View Stereo

ACMMP [News] The code for ACMH is released!!! [News] The code for ACMM is released!!! [News] The code for ACMP is released!!! About This repository co

Nov 24, 2022
A fast multi-producer, multi-consumer lock-free concurrent queue for C++11

moodycamel::ConcurrentQueue An industrial-strength lock-free queue for C++. Note: If all you need is a single-producer, single-consumer queue, I have

Dec 2, 2022
A bounded multi-producer multi-consumer concurrent queue written in C++11
A bounded multi-producer multi-consumer concurrent queue written in C++11

MPMCQueue.h A bounded multi-producer multi-consumer concurrent queue written in C++11. It's battle hardened and used daily in production: In the Frost

Dec 1, 2022
A reverse engineering tool to interactively reconstruct structures and generate header files
A reverse engineering tool to interactively reconstruct structures and generate header files

ReGenny ReGenny is a reverse engineering tool to interactively reconstruct structures and generate usable C++ header files. Header file generation is

Nov 27, 2022
A library of generic data structures.

Collections-C A library of generic data structures including a list, array, hashtable, deque etc.. Examples Building and Installing Using the library

Nov 28, 2022
🔗 Common Data Structures and Algorithms

?? Data Structures and Algorithms This library provides common data structures. It will also provide some data structures which needed in render or ga

Oct 13, 2022
A collecton of generic reference counted data structures, tools to create compatible C style classes, and demo applications

The Offbrand library is a collection of reference counted generic data structures written in C for C. The library includes bash scripts to assist in t

Nov 21, 2022
Repository of problems and solutions of labsheets used for Data Structures and Algorithms (CS F211) in Semester 2, 2020-21 at BITS Pilani - Hyderabad Campus.

CS F211 Data Structures and Algorithms (BITS Pilani - Hyderabad Campus) This repository contains the problems, solution approaches & explanations and

Oct 31, 2022
An assortment of commonly used algorithms and data structures implemented with C++.

Algorithms-And-Data-Structures This repo contains C++ implementations of common algorithms and data structures, grouped by topics. The list will be sp

Nov 9, 2021