srdja/Collections-C logo

srdja/Collections-C

Free

A library of generic data structures for the C language.

FreeFree tier
Type
Open Source

About srdja/Collections-C

Collections-C is a C language library providing a range of generic, reusable data structures. It includes pointer containers (storing void* pointers) such as dynamic arrays (CC_Array), doubly and singly linked lists (CC_List, CC_SList), deques, hash tables, tree tables, sets, queues, stacks, priority queues, ring buffers, and ternary search tree tables. Sized containers store data of arbitrary length directly (e.g., CC_SizedArray). Memory pools (CC_DynamicPool, CC_StaticPool) enable pre-allocated memory blocks for performance-critical applications. The library emphasizes efficiency with constant or logarithmic time operations for common use cases and is designed for easy integration into C projects via CMake build system.

Key Features

Pointer containers storing void* pointers (CC_Array, CC_List, CC_SList, CC_Deque, CC_HashTable, CC_TreeTable, CC_HashSet, CC_TreeSet, CC_Queue, CC_Stack, CC_PQueue, CC_RingBuffer, CC_TSTTable)
Sized containers storing arbitrary-length data directly (CC_SizedArray)
Memory pools for pre-allocated contiguous memory (CC_DynamicPool on heap, CC_StaticPool fixed pool)
Constant time or logarithmic time operations for insertion, removal, and lookup on various containers
CMake-based build system for cross-platform compilation
Open-source with permissive license (COPYING file referenced)

Pros & Cons

Pros
  • Comprehensive collection of data structures covering most common needs
  • Well-documented API with usage examples
  • Memory pool support for fine-grained memory management
  • Open source with active community (3k stars, 332 forks)
  • Portable C code (no external dependencies beyond standard C)
Cons
  • C language only – not directly usable from C++ or other languages without wrappers
  • No built-in thread safety; concurrency must be handled externally
  • Limited to pointer-based or sized containers; no built-in support for custom allocators beyond memory pools
  • Documentation is mostly in code comments and README; may lack extensive tutorials

Best For

Implementing efficient data structures in embedded systems where memory and performance are criticalBuilding parsers, compilers, or interpreters that need stacks, queues, or symbol tablesDeveloping any C application requiring generic, reusable containers without reinventing the wheelEducational purposes for learning data structure implementations in C

FAQ

What data structures does Collections-C include?
It includes arrays, lists, deques, hash tables, tree tables, hash sets, tree sets, queues, stacks, priority queues, ring buffers, and ternary search tree tables.
How do I build Collections-C?
The project uses CMake. You can build with standard CMake commands: mkdir build && cd build && cmake .. && make.
Is Collections-C thread-safe?
The library does not provide built-in synchronization. Users must implement their own locking for concurrent access.