An associative array implemented by C laugnage

Related tags

Miscellaneous cmap
Overview

C Map

An associative array implemented by C laugnage.

  • This is an implementation of an associative array written by C. it is similar as C++ but it is implemented by C; thus, this repo calls it cmap (C++ ).

Implementation

  • The goal of this repo is providing a binary search tree for the programmers using C language to work on thier projects. But, here is only a simple implementation of Red-Black Tree, which is known as a self-balancing binary search tree, and hopes it can be a helpful data structure for the projects written by C language.
  • cmap is an implementation with OOP style; when using cmap, you must manipulate it as an 'object' in any OOP language.

Usage

  • Before using cmap, you have to define the three functions with the specific types by yourself.
// A comparator for keys of Red-Black Tree.
int cmp(const void *key1, const void *key2) {
	/* return -1, 0, 1. */;
	/* You may understant this quickly if you had used qsort in your C projects. */
}

// A function for getting the memory size of key.
size_t key_size_get(const void *key) {
	/* returning the size of key. */
}

// A function for getting the memory size of value.
size_t val_size_get(const void *val) {
	/* returning the size of value */
}

Example for using cmap.

test/main.c

Methods of cmap.

void *(*const search)(cmap_t *, const void *);
void (*const insert)(cmap_t *, const void *, const void *);
bool (*const erase)(cmap_t *, const void *);
void (*destroy)(cmap_t *);

TODO

  • erase is incomplete, and others are finished but can be improved more efficient.
  • Other operators about Red-Black Tree.

Build

  1. A simple test file: test/main.c
    • This shows how to construct and use a cmap, and some of details has been descripted above.
    • In this case, The types of key and value of cmap are C string and integer, respectively.
make build
./main
  1. A test file to test Red-Black Tree: test/test1.c
    • This program also test a cmap, whose types is identified as the cmap in test/main.c
    • There has twelve nodes constructed by the program and input some test data from test/test.in to search the cmap and get the corresponding value.
make test1

Better usage

  • (To be continued...)
You might also like...
ADTW demonstration application - implemented with EAP

Amerced DTW demonstration application Amerced DTW (ADTW) is a variant of DTW, "amercing" ("penalizing") warping steps by a fixed penalty. This is a NN

A C++ implemented set of 8,16,32,64 bit cyclic redundancy check (CRC) functions conforming to the CRC spec given by AUTOSAR

A C++ implemented set of 8,16,32,64 bit cyclic redundancy check (CRC) functions conforming to the CRC spec given by AUTOSAR. Written in C++ and compiled as a 'C++ addon' for use in JavaScript. Available on NPM.

Playbit System interface defines an OS-like computing platform which can be implemented on a wide range of hosts

PlaySys The Playbit System interface PlaySys defines an OS-like computing platform which can be implemented on a wide range of hosts like Linux, BSD,

 A CPU implemented in an analog modular synthesizer
A CPU implemented in an analog modular synthesizer

A CPU implemented in an analog modular synthesizer This runs in the VCV Rack eurorack simulator. I wrote a thread explaining the CPU on twitter and a

Compile-time C Compiler implemented as C++14 constant expressions

constexpr-8cc: Compile-time C Compiler constexpr-8cc is a compile-time C compiler implemented as C++14 constant expressions. This enables you to compi

All algorithms implemented in C

C Algorithms All algorithms implemented in C (for learning) Contribute algorithms written in C language. It's beginner friendly! Feel free to add new

ToPS is an objected-oriented framework implemented using C++ that facilitates the integration of probabilistic models for sequences over a user defined alphabet

ToPS is an objected-oriented framework implemented using C++ that facilitates the integration of probabilistic models for sequences over a user defined alphabet

EspHoMaTriX - A simple DIY status display with an 8x32 RGB LED panel implemented with esphome.io

EspHoMaTriX (ehmtx) A simple DIY status display with an 8x32 RGB LED panel implemented with esphome.io Introduction There are some status displays out

DigiMahal is the First Project of Our Team in Sharif University of Technology for Basics of Programming That in this Code we Implemented an Online Shop like DigiKala
DigiMahal is the First Project of Our Team in Sharif University of Technology for Basics of Programming That in this Code we Implemented an Online Shop like DigiKala

DigiMahal is the First Project of Our Team in Sharif University of Technology for Basics of Programming That in this Code we Implemented an Online Shop like DigiKala.

Owner
Dr.Xiao
Dr.Xiao
Flat map - Header only associative linear container.

flat_map flat_map is a header only associative container library that constructed on linear container. It compliants C++17/20 standard associative con

Kohei Takahashi 24 Aug 26, 2022
Vaccine Monitor app implemented in C with system Programming techniques.Projects implemented as part of the course Syspro K24

System_Programming_Projects Vaccine Monitor app implemented in C with system Programming techniques.Projects implemented as part of the course Syspro

Aristi_Papastavrou 10 Dec 30, 2021
J is an array programming language

J: From C to C++20 J is an array programming language created by Ken Iverson and Roger Hui (see image below).

Conor Hoekstra 37 Oct 28, 2022
Manual map shellcode (aka byte array) injector

ShellJector This little tool can download DLL from the internet and inject it as shellcode (aka byte array) into process with manual map injection. Th

Александр Вольф 25 Jan 3, 2023
A C++ library with all the online array problems and etc which I get online

cpp-Library A C++ library with all the online array problems and etc which I get online. Setup To setup it simply just download the repo and then move

Padmashree Jha 6 Dec 6, 2021
Dynamic array supporting Range Minimum Queries

dynamic-RMQ Dynamic array supporting Range Minimum Queries. Data structure that represent a dynamic array supporting Range Minimum Queries. The data s

Massimiliano Rossi 4 Aug 24, 2022
An experimental sprite rendering setup utilizing SSBO's, Threading, EnTT reactive systems, and array-textures based sprite caching.

entt-reactive An experimental sprite rendering setup utilizing pooled SSBO's, a multithreaded setup based on Even Todd's The Poor Man's Threading Arch

Jackie Fuchs 7 Apr 29, 2022
Tiny project to convert a .ase to a RGBA Byte array

Tiny project to convert a .ase to a RGBA Byte array

Stephen Ma 3 Apr 6, 2021
Solving Kepler's equation via contour integration, implemented in C++

Kepler's Goat Herd Code for solving Kepler's equation using contour integration, following Philcox et al. (2021, arXiv). This uses a method originally

Oliver Philcox 45 Sep 11, 2022
brainfuck interpreter and repl with some optimizations implemented in.

bfc brainfuck interpreter and repl with some optimizations implemented in. building bfc uses premake5 to generate the required build files. main:bfc (

nwxnk 5 Dec 9, 2021