Skip to content
/ PureC_DataStructs Public template

Implementing all common data structures in pure C with the help of magic

Notifications You must be signed in to change notification settings

Savvelius/PureC_DataStructs

Repository files navigation

Implementing generic data structures in pure C

The philosophy is:

  • All dynamic data structures are of type byte* (typedefed char) - helps to unify all the functionality and maintain generic types.
  • Interaction with these data structures must happen only with given functionality.
  • Getting elements of given data structure happens either with subscription [] operator or with it's %NAME%_getitem() function, which checks for out of bounds.
  • All memory interaction happens via memory.h module functionality.
  • All data structures are based on dynamic array.
  • In every module, data structure's functions are named: %struct name in uppercase%_%method functionality in lowercase%
  • Before every data structure lies a 'header' struct which contains main information about the array. This header leads to O(1) time for getting structure's length, capacity, element size and other crucial parameters.

Note:

Code like this:
DA_append(array, 10)

will not work, because of the internal memcpy mechnism that any insertion invokes. Therefore, (for now) only further code is valid:

int elem = 10;
DA_append(array, elem);

About

Implementing all common data structures in pure C with the help of magic

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages