/air-ctl

C Language Template Library C语言 模板库

Primary LanguageCBoost Software License 1.0BSL-1.0

CTL

C Language Template Library

Install

//use vcpkg install
vcpkg install air-ctl

// or use git
git clone https://github.com/inie0722/CTL
cd CTL
mkdir build && cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release
cmake --build ./ --config Release --target install

//run test
cmake ../ -DCMAKE_BUILD_TYPE=Release -DTest=ON
make check && ctest

Container task lists

  • array
  • vector
  • deque
  • list
  • hash map
  • tree map
  • queue
  • stack
  • heap
  • priority queue

Algorithm task lists

  • heap sort
  • insertion sort
  • intro sort
  • quick sort
  • tim sort

Lockfree task lists

  • spsc queue
  • mpmc queue
  • queue
  • stack
  • aba pointer
  • allocator

About

This library is a C language container library written by imitating STL, you can use this library like STL
If you want to see the specific container usage method, you can go to the documentation The code implementation is modeled after SGI-STL

Note

For memory overflow, function callback is used, which means that all APIs will not return the error of memory allocation failure, but you need to set the OOM callback function yourself

void CTL_set_malloc_handler(void (*handler)()); //Memory allocation failure Handler function Defined 

This library provides two different map
tree_map Implemented using a red-black tree, allowing the same key to be typed, and using a callback function for key comparison and judgment
hash_map Implemented using an open-chain hash table, it is not allowed to enter the same key, and use memcmp for key comparison judgment, you need to pay extra attention to this

Sort Algorithm
This library only provides a heap sort, which is suitable for containers that support random access such as deque vector array
If you need to use other sort algorithms, you can use algorithm
It provides two advanced sort algorithms intro_sort and tim_sort
The former is unstable, and it is faster to sort out-of-order data
The latter is stable, and sorting is faster for partially ordered data

Other

For the API, I can't promise any compatibility
Because of my limited ability, I cannot ensure that every API is correct. If you find a bug, please let me know in time
If you like this library, you can give me a star