133 Commits
Author SHA1 Message Date
Leonardo Vencovsky b51efa5c45 v0.24.0 2020-06-26 00:02:13 -03:00
Leonardo Vencovsky 835caa8333 Forwarding changes 2020-06-26 00:01:41 -03:00
Leonardo Vencovsky 645b02708d Create STATUS 2020-06-26 00:01:08 -03:00
Leonardo Vencovsky fa2e3d1fcd Adding dfs example and fixing other examples 2020-06-24 21:55:20 -03:00
Leonardo Vencovsky 4d4f1256ee Some fixes to treeset and flags 2020-06-24 19:31:42 -03:00
Leonardo Vencovsky fe056c1b06 Some fixes to bitset 2020-06-24 16:57:38 -03:00
Leonardo Vencovsky ce470f50b5 Update .travis.yml 2020-06-23 23:17:54 -03:00
Leonardo Vencovsky a23dfb0ab0 Update .travis.yml 2020-06-23 22:34:30 -03:00
Leonardo Vencovsky c93f4bac6b Update autogen.py 2020-06-23 22:09:09 -03:00
Leonardo Vencovsky e1bb3542ee Updating autogen.py 2020-06-22 23:27:20 -03:00
Leonardo Vencovsky a1e0a4edbb Updating autogen script 2020-06-20 12:12:47 -03:00
Leonardo Vencovsky feaac16804 Update benchmark 2020-06-19 22:37:25 -03:00
Leonardo Vencovsky 66b6677afa Quick fix 2020-06-19 19:38:55 -03:00
Leonardo Vencovsky f80b17ff82 Updating script and formatting files 2020-06-17 21:38:00 -03:00
Leonardo Vencovsky c16ecd886c Fixing errors found in types.c tests 2020-06-16 23:43:15 -03:00
Leonardo Vencovsky 922d8b01b8 Update types.c 2020-06-16 23:38:20 -03:00
Leonardo Vencovsky 203516d8cf v0.24.0 preview 2020-06-12 12:34:33 -03:00
Leonardo Vencovsky 767fc0d7fd Update .travis.yml 2020-06-11 22:39:46 -03:00
Leonardo Vencovsky 10e0b4b397 Update .travis.yml 2020-06-11 22:16:34 -03:00
Leonardo Vencovsky 22ab6fdb64 Update .travis.yml 2020-06-11 22:11:22 -03:00
Leonardo Vencovsky e08a8f89f3 Update autogen.py and travis 2020-06-11 22:04:23 -03:00
Leonardo Vencovsky 4bebb90cb6 Tests reworked - CI might not work 2020-06-11 21:23:42 -03:00
Leonardo Vencovsky f8607e8cdc Now it is possible to have opaque collections
PUBLIC and PRIVATE are back
2020-06-11 00:39:56 -03:00
Leonardo Vencovsky 2b8f778c59 Fixing some things, tests resumed 2020-06-08 21:14:56 -03:00
Leonardo Vencovsky aec7efd4c3 Finishing migration to EXT 2020-06-08 20:07:46 -03:00
Leonardo Vencovsky 1987152b03 More things added to EXT 2020-06-07 16:30:23 -03:00
Leonardo Vencovsky 649f02665f Code formatting and moving more things around 2020-06-06 08:32:35 -03:00
Leonardo Vencovsky 59a1e2a682 Somewhat working optional callbacks 2020-06-05 15:46:52 -03:00
Leonardo Vencovsky e85bc72203 Moving more stuff to EXT and fixing typo 2020-06-05 10:47:57 -03:00
Leonardo Vencovsky aa033b0316 Massive changes, unit tests halted
Code format changes that significantly reduce file sizes
Working towards many new features at the same time
Callbacks are going to be optional
Everything is still breaking
2020-06-04 17:20:47 -03:00
Leonardo Vencovsky 770ec1c4c7 More migrations to EXT 2020-06-04 00:33:13 -03:00
Leonardo Vencovsky 90a6b4ef0d Hash CORE no longer depends on ITER and moved some other things to EXT 2020-06-03 20:07:03 -03:00
Leonardo Vencovsky 63eb525406 Moving more things to EXT 2020-06-03 18:38:49 -03:00
Leonardo Vencovsky 97f46b3a81 More stuff moved to EXT 2020-06-02 15:20:34 -03:00
Leonardo Vencovsky 424ba074ff Inlining string_fmt and fixing some unused warnings with __attribute__ 2020-06-02 11:14:34 -03:00
Leonardo Vencovsky 9209e0d5ec Refactoring
Now using CMC_DEF_FTAB macros
Renamed BODY to PARAMS
2020-06-01 20:01:54 -03:00
Leonardo Vencovsky 546ac80030 Adding more things to EXT and some changes to heap 2020-06-01 15:33:17 -03:00
Leonardo Vencovsky 69eed72838 Adding the folder path to file names 2020-06-01 13:59:03 -03:00
Leonardo Vencovsky ce4fadff01 Hotfix 2020-05-31 01:00:13 -03:00
Leonardo Vencovsky 624d1613f0 Adding and fixing things, documenting code and moving more stuff to EXT 2020-05-31 00:50:55 -03:00
Leonardo Vencovsky b85f3d1f81 Some refactoring and moving more stuff to EXT 2020-05-30 00:05:46 -03:00
Leonardo Vencovsky 89254ab5db Started migrating things to EXT 2020-05-29 20:19:47 -03:00
Leonardo Vencovsky e39d60ade9 Moving components to ext and updating tests/to_string.c for reference 2020-05-27 01:19:58 -03:00
Leonardo Vencovsky 77a7178857 Added ./cor/ftable.h and fast forward changes 2020-05-27 00:48:34 -03:00
Leonardo Vencovsky 85bef64551 Fast forward changes on new way to generate macros 2020-05-26 17:25:43 -03:00
Leonardo Vencovsky 720e55bfcc Moved params to core and some code cleanup 2020-05-26 15:32:34 -03:00
Leonardo Vencovsky 8e0183a7d7 Update autogen.py 2020-05-26 14:21:23 -03:00
Leonardo Vencovsky 7fa0eafd2c A lot of changes
Changed include guards
Removed struct cmc_flags, now using enum
Token concatenation now uses CMC_
Every concatenation with SNAME now uses a special macro (this allows customization)
Deleted some no longer needed test files
Deleted some very old implementations of dev and sac collections
2020-05-26 14:00:45 -03:00
Leonardo Vencovsky e9ee0a88b7 Added ext folder with some initial parts already using the new API 2020-05-25 22:09:45 -03:00
Leonardo Vencovsky ab776dd7f3 Added ./cor/params.h 2020-05-25 22:08:05 -03:00
Leonardo Vencovsky a9661c3485 Updating cor include guards and separating things from core.h 2020-05-24 13:40:54 -03:00
Leonardo Vencovsky 9680f6a923 v0.23.1 2020-05-23 09:01:28 -03:00
Leonardo Vencovsky aa53485d62 Added foreach tests 2020-05-23 08:49:17 -03:00
Leonardo Vencovsky 8112ea6f42 Bug fixes to hashmultiset 2020-05-23 07:46:23 -03:00
Leonardo 7340866da1 Added include guards to test src and formatting tests 2020-05-21 21:19:03 -03:00
Leonardo e4a7b01d3a Updating foreach macros with the new iterators API 2020-05-20 20:04:19 -03:00
Leonardo 7c82fff41d Added cor/bitset.h 2020-05-20 19:33:37 -03:00
Leonardo 160c6d4d1c v0.23.0
The version was reset to comply with SemVer
2020-05-19 14:08:56 -03:00
Leonardo 9081734fc9 Fixing includes in macro_collections.h 2020-05-19 13:04:07 -03:00
Leonardo 7c53d0c516 Added missing include guards to mutex.h and thread.h 2020-05-19 12:58:26 -03:00
Leonardo 4402a70415 Updating treeset iterator API 2020-05-18 19:17:57 -03:00
Leonardo 2a919483e0 Updating treemap iterator API 2020-05-18 15:46:03 -03:00
Leonardo 14251ea378 Added more bitset functions 2020-05-16 08:17:52 -03:00
Leonardo d0958c7d0c Update README.md
Added new badge
2020-05-15 00:01:51 -03:00
Leonardo f0e116293f Update github actions 2020-05-14 23:43:02 -03:00
Leonardo Vencovsky 0e34f21aab Create c.yml 2020-05-14 22:49:58 -03:00
Leonardo ea36906d02 Added mutex.h and thread.h 2020-05-14 20:18:00 -03:00
Leonardo f520c38583 Added flags.h
Separated flag definitions from the core header
2020-05-14 18:43:43 -03:00
Leonardo 1380d131ea Added bitset flip and flip_range 2020-05-14 16:10:04 -03:00
Leonardo bd96dfdc8f Update README.md 2020-05-13 15:20:39 -03:00
Leonardo e86950d4ab Update autogen.py 2020-05-13 01:42:39 -03:00
Leonardo 13e3f6047b Minor fixes 2020-05-12 16:04:40 -03:00
Leonardo 51d7a58424 Updating stack iterators 2020-05-12 16:02:42 -03:00
Leonardo 360e08b6b3 Updating sortedlist iterators 2020-05-12 13:53:28 -03:00
Leonardo 7fa41df65a Updating queue iterators API 2020-05-11 16:46:58 -03:00
Leonardo 66c829701d Updated list iterator API 2020-05-10 21:58:10 -03:00
Leonardo 9cd3bf3b31 Removed unused it_start and it_end 2020-05-10 21:52:27 -03:00
Leonardo 8fc432b76c Updating linkedlist iterator 2020-05-09 09:16:51 -03:00
Leonardo 2f59d5fcaf Updatating intervalheap iterator and other smaller things 2020-05-09 07:58:03 -03:00
Leonardo 3bb7f241f2 Added missing HeapIter test to the main unit test suit 2020-05-08 20:59:50 -03:00
Leonardo 9f596f7974 Updating heap API and fixing some things 2020-05-08 20:56:01 -03:00
Leonardo bf3535970e Added the possibility of running tests from each collection separately
Also added CMC_BITSET_WORD_TYPE so that the type of the bitset buffer can be defined with the -D flag
2020-05-07 22:19:09 -03:00
Leonardo 981fef3def Added CMC_TO_STRING macro 2020-05-07 21:50:22 -03:00
Leonardo 303e3b57b8 Updating hashset iterator API 2020-05-07 00:10:41 -03:00
Leonardo adfa5abbc0 Update README.md 2020-05-06 20:44:08 -03:00
Leonardo 2cacbc5348 Updating hashmultiset iterator API 2020-05-06 20:43:59 -03:00
Leonardo fdfb81d08c Updating hashmultimap iterator API 2020-05-06 14:55:44 -03:00
Leonardo 254bb3eacc Renamed multiset to hashmultiset 2020-05-05 18:13:17 -03:00
Leonardo c41ce371d3 Renamed multimap to hashmultimap 2020-05-05 18:00:56 -03:00
Leonardo 9962981047 Added initial bitset documentation 2020-05-05 17:42:06 -03:00
Leonardo b35281b8dc Renaming bidimap to hashbidimap 2020-05-04 23:02:57 -03:00
Leonardo c58f3df50a More added to bitset 2020-05-04 18:19:18 -03:00
Leonardo 963056c42d Update README.md 2020-05-02 01:14:33 -03:00
Leonardo fb0674b0c7 Update core.h 2020-05-02 00:32:40 -03:00
Leonardo 7ad2462254 Adding bitset checkpoint 2020-05-01 15:52:37 -03:00
Leonardo 53f6202709 Updating documentation 2020-04-30 23:39:09 -03:00
Leonardo 0702b7f51b Update hashmap tests and its iterator API 2020-04-29 22:40:07 -03:00
Leonardo 9ade952392 Fixing hashtables and added hashmap init and release 2020-04-29 20:08:42 -03:00
Leonardo 5d68dcc538 Fixing imports in tests 2020-04-29 00:39:20 -03:00
Leonardo 3c0ce0a623 Update deque tests and its iterator API 2020-04-28 22:52:01 -03:00
Leonardo 27ac934ab6 Added new functions to deque and changed iterator functions
New functions: init, init_custom, release
Added DequeIter unit tests
2020-04-27 20:19:47 -03:00
Leonardo db6f12d3e8 Update documentation 2020-04-23 00:11:16 -03:00
Leonardo Vencovsky 3d9abc66a7 Formatting some files 2020-04-23 00:03:57 -03:00
Leonardo Vencovsky af5abff115 Adding more deque tests and valgrind option to tests makefile
Also added a nice header for the main unit test
2020-04-23 00:03:17 -03:00
Leonardo Vencovsky 64201cb630 Fixing memory leaks and indexes out of bounds 2020-04-22 18:38:05 -03:00
Leonardo 6d4b8618bf Fixing autogen.py for linux 2020-04-22 15:34:51 -03:00
Leonardo fe78937150 Replaced unnecessary node struct from intervalheap to a buffer of array[2] 2020-04-22 11:51:05 -03:00
Leonardo 5af021ec0a Fixing some things with intervalheap and added more tests 2020-04-22 10:08:06 -03:00
Leonardo 2e48a033a0 Refactoring: renaming 'element' to 'value' 2020-04-21 01:38:26 -03:00
Leonardo 980fb6d432 Fixing test.h, fixing warnings and deque tests 2020-04-20 01:15:51 -03:00
Leonardo 181a8999a7 Update deque tests 2020-04-19 13:08:38 -03:00
Leonardo 05883903c9 Update documentation and quick fix to test.h 2020-04-18 00:05:20 -03:00
Leonardo 656c0e3b3a Added cmc_assert_total, cmc_assert_failed, better-looking unit test and other things
Started using functions from futils.h in unit test
Renamed unit tests
2020-04-17 16:29:52 -03:00
Leonardo 6f1fb7554e Update documentation 2020-04-17 01:33:49 -03:00
Leonardo 2a7aa8e4cb Added ./cor headers to macro_collections.h for completeness and added formatting 2020-04-17 01:03:13 -03:00
Leonardo 831037df42 Added cmc_flags_to_str 2020-04-16 21:45:58 -03:00
Leonardo 277139656e Fixing missing flag for treemap and treeset 2020-04-16 20:29:49 -03:00
Leonardo e1c736ab46 Adding futils.h to macro_collections.h 2020-04-16 02:10:20 -03:00
Leonardo 952292462a Update documentation 2020-04-16 02:08:42 -03:00
Leonardo 14845d9b23 Adding missing 'static inline' to futils functions 2020-04-15 20:18:35 -03:00
Leonardo cd8260a879 Update futils.h 2020-04-15 19:50:32 -03:00
Leonardo 5cf8904c58 Added futils.h with utility functions for Functions Table 2020-04-15 19:19:09 -03:00
Leonardo 75f2756611 Changed foreach include guard to CMC_FOREACH_H 2020-04-15 14:48:30 -03:00
Leonardo eb13fcad01 Simplified name for functions table ftab_key to fkey and ftab_val to fval 2020-04-14 23:18:56 -03:00
Leonardo 5e13c7ba91 Update travis and fixing tests 2020-04-13 13:10:04 -03:00
Leonardo 7701364f13 Merging tests codecov with main 2020-04-13 12:13:41 -03:00
Leonardo 1dd0f25ff8 Added script that automatically generates code for code coverage 2020-04-12 21:11:37 -03:00
Leonardo 8e73cde6ae Fast-forward codecov 2020-04-11 14:14:34 -03:00
Leonardo 67590790c4 Documentation for foreach.h, test.h, timer.h and other changes
Change in timer.h. Now cmc_timer_stop will calculate the result so goodbye cmc_timer_calc
2020-04-10 22:21:47 -03:00
Leonardo aa214d179e Some changes do log.h and adding its documentation 2020-04-09 22:04:19 -03:00
Leonardo da6f5ea05c Fixing logo 2020-04-09 13:45:15 -03:00
Leonardo 480b99b384 Update documentation 2020-04-09 01:05:04 -03:00
Leonardo 56326b2dd9 Updating tests for bidimap 2020-04-08 19:35:34 -03:00
276 changed files with 57963 additions and 41556 deletions

No files matched your search

+2 -2
View File
@@ -1,13 +1,13 @@
# clang-format 9.0.0
Language: Cpp
BasedOnStyle: LLVM
AlignEscapedNewlines: Left
AlignEscapedNewlines: DontAlign
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Allman
BreakStringLiterals: false
ColumnLimit: 80
ColumnLimit: 120
Cpp11BracedListStyle: false
ForEachMacros: ["CMC_FOREACH", "CMC_FOREACH_REV"]
IndentCaseLabels: true
+17
View File
@@ -0,0 +1,17 @@
name: Test Suit
on:
push:
branches: [ master ]
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Environment
run: sudo apt install make valgrind gcc python
- name: Test Suite
run: python autogen.py -e -b -r -nf
# - name: Valgrind Test
# run: make -C ./tests/main valgrind
+3
View File
@@ -56,3 +56,6 @@ dkms.conf
# Experimental folder
experimental/
# Test / Code Coverage build folder
build
+11 -7
View File
@@ -1,19 +1,23 @@
dist: trusty
dist: xenial
os: linux
language: c
compiler: gcc
addons:
apt:
sources:
- deadsnakes
- ubuntu-toolchain-r-test
packages:
- gcc-7
- gcc-9
- cmake
- python3.8
script:
- sudo ln -s /usr/bin/gcc-6 /usr/local/bin/gcc
- export CC=gcc-7
# - make -C ./tests/
- make -C ./tests/main/
- make -C ./tests/codecov/
- sudo ln -s /usr/bin/gcc-9 /usr/local/bin/gcc
- sudo ln -s /usr/bin/gcov-9 /usr/local/bin/gcov
- sudo ln -s /usr/bin/python3.8 /usr/local/bin/python
- gcc --version
- gcov --version
- python --version
- python autogen.py -e -b -cv -r -nf
after_success:
- bash <(curl -s https://codecov.io/bash)
+70 -29
View File
@@ -1,6 +1,47 @@
# RELEASE.MAJOR.MINOR
1.8.0
0.24.0
A lot of breaking changes, with the library more modular now
Comeback of PUBLIC and PRIVATE for the CMC sub-library
Callbacks are now optional and can be turned off by defining CMC_NO_CALLBACKS
Added EXT library
New macro CMC_CAMEL_CASE can change the library's style where the default is snake case
Added:
./cor/alloc.h
./cor/callbacks.h
./cor/heap.h
Complete rework of tests and code coverage using autogen.py
Removed cmc_flags, where now every flag is an enum (CMC_FLAGS_OK, CMC_FLAGS_ERROR, etc)
Different include guards
New way to generate code using PARAM
Code now completely changed by using the CMC_ macro to concatenate tokens
Token concatenation with SNAME now uses special macros that allow customization of the suffixes
0.23.1
Added ./cor/bitset.h
Added foreach tests
Updating foreach macros with the new iterators API
Bug fixes for ./cmc/hashmultiset.h
0.23.0
Added ./cmc/bitset.h
Added ./cor/flags.h
Added ./utl/futils.h
Added ./utl/mutex.h
Added ./utl/thread.h
Added cmc_flags_to_str
Added autogen.py for automated code generation for code coverage
Changed the iterator API
Merged ./tests/codecov and ./tests/main
Renamed ftab_key to fkey and ftab_val to fval
Renamed collections
- bidimap -> hashbidimap
- multimap -> hashmultimap
- multiset -> hashmultiset
-- Versioning restarted for compatibility with SemVer (https://semver.org/)
1.8.0 (0.22.0)
Added Function Tables
Added Error Codes
Added Callback Functions
@@ -14,13 +55,13 @@
Removed ./utl/cmc_string.h
Replaced CMC_FOR_EACH and CMC_FOR_EACH_REV by CMC_FOREACH and CMC_FOREACH_REV
1.7.3
1.7.3 (0.21.0)
Breaking changes:
- ext collections merged to cmc
- No more typedefs in code generated
Fast forwarded codecov
1.7.2
1.7.2 (0.20.0)
Added resize function to array based collections
Added the following functions to hashtable based collections:
- load
@@ -31,18 +72,18 @@
Removed unnecessary conditional input and output functions
Minor fixes throughout the library
1.7.1
1.7.1 (0.19.0)
Added new assert macro cmc_assert_sorted
Fixed some include guards for hashtables
Moved the cmc string format to each file
Renamed some list functions (sequence input/output)
Renamed list and linkedlist functions push and pop to push_at and pop_at
1.7.0
1.7.0 (0.18.0)
Removed FMOD (function modifier)
Added CMC prefix to all macros defined within the library
1.6.3
1.6.3 (0.17.0)
Added iterator functions to all collections:
- iter_advance
- iter_rewind
@@ -50,7 +91,7 @@
Added cmc prefix to the logging utility
Integrated the assert utility with the test utility. Now any assertion that fails inside the unit test will trigger failure and is no longer needed to manually pass or fail tests.
1.6.2
1.6.2 (0.16.0)
Added new functions to all collections:
- copy_of
- equals
@@ -58,11 +99,11 @@
Fixed some collections and some improvements to the hashtables
Unified the functions set and update from the map implementations
1.6.1
1.6.1 (0.15.0)
Removed ./ext/linkedqueue.h
Added a deallocator parameter to all _free and _clear functions
1.6.0
1.6.0 (0.14.0)
Added ./ext/intervalheap.h
Added ./ext/multimap.h
Added ./ext/multiset.h
@@ -72,12 +113,12 @@
Fixed hashtables integer overflow when the capacity is divided by the load factor
Changed timer.h struct name from timer_t to cmc_timer to prevent name collisions on linux
1.5.3
1.5.3 (0.13.0)
Tests completely reorganized and now with full code coverage
Some fixes where there was a missing return statement
Expanded ./utl/assert.h
1.5.2
1.5.2 (0.12.0)
Added ./utl/test.h
Added ./utl/assert.h
Added ./tests/list.c - UnitTest for LIST
@@ -85,13 +126,13 @@
Removed ./utl/log.h functions that were unnecessary
Added the CMC namespace to CONCATC and CONCATH at macro_collections.h
1.5.1
1.5.1 (0.11.0)
New queue benchmark
Added ./sac/queue.h
Added ./utl/timer.h
Fixing descriptions and other minor fixes
1.5.0
1.5.0 (0.10.0)
Changed tests compilation and execution to a single Makefile
Changed project structure
./src/
@@ -105,7 +146,7 @@
Added ./ext/linkedqueue.h - A singly-linked list based queue
Added ./sac/stack.h - A Stack purely allocated on the stack
1.4.3
1.4.3 (0.9.0)
Fixed some functions names
Added set functions for both Tree and Hash Set
- is_subset
@@ -114,7 +155,7 @@
- is_proper_subset
- is_disjointset
1.4.2
1.4.2 (0.8.0)
Adapted code so that plain struct type is accepted
Changed TreeSet max and min to be compatible with the TreeMap and the hash collections
Changed function modifier of all implementation detail to static
@@ -122,12 +163,12 @@
Added types.c to test if it is possible to compile all the collections' generated code accepting all C data types
Removed pointertype.c (replaced by types.c)
1.4.1
1.4.1 (0.7.0)
Removed PUBLIC and PRIVATE from the main macro
Corrected examples and benchmark
Added new test consisting of compiling the header and source separately
1.4.0
1.4.0 (0.6.0)
New way on how iterators work to all collections
Added iter_init to work with stack allocated iterators
Added iter_new and iter_free to work with heap allocated iterators
@@ -139,48 +180,48 @@
Changed pointertype test to be a pointer to struct instead of pointer to char
Added CHANGELOG and TODO
1.3.0
1.3.0 (0.5.0)
Changed how the linkedlist functions relative to nodes work
Removed reference to owner list on each node
Renamed some functions for consistency
1.2.4
1.2.4 (0.4.1)
Fixing some declarations in hashset and hashmap where a pointer type would cause problems
Added a test to make sure all collections support pointer type
Tests:
- pointertype
1.2.3
1.2.3 (0.4.0)
Added get_ref functions to all collections that support it (only included in hashmap, linkedlist, list and treemap)
1.2.2
1.2.2 (0.3.2)
Removed unnecessary modulo operation in hashtable functions
1.2.1
1.2.1 (0.3.1)
Optimized list - now using 'string.h' functions to shift elements around instead of for-loops:
- memset
- memcpy
- memmove
1.2.0
1.2.0 (0.3.0)
'contains' functions added to all collections
'contains' tests and benchmark
Unified Benchmark
Updated examples
1.1.3
1.1.3 (0.2.3)
Renamed deque's 'rear' struct member to 'back' to be more consistent with other collections
Better benchmark and foreach tests are alphabetically ordered
1.1.2
1.1.2 (0.2.2)
Fixing iterators for when they are initialized with an empty target
Better iterator tests
More examples
1.1.1
1.1.1 (0.2.1)
Reordering functions (implementation details are now at the end of each file)
1.1.0
1.1.0 (0.2.0)
Added new list functions:
- new_from
- prepend
@@ -189,10 +230,10 @@
- remove
- fits
1.0.1
1.0.1 (0.1.1)
Fixed hashset logic in robin-hood hashing
1.0.0
1.0.0 (0.1.0)
First stable version
Includes the following collections:
- deque
-22
View File
@@ -1,22 +0,0 @@
# This file is useful to format all the source files and header in this library using clang-format
.PHONY: all cmc dev sac utl tests FORCE
all: cmc dev sac utl tests
cmc: FORCE
clang-format --style=file -i ./src/cmc/*.h
dev: FORCE
clang-format --style=file -i ./src/dev/*.h
sac: FORCE
clang-format --style=file -i ./src/sac/*.h
utl: FORCE
clang-format --style=file -i ./src/utl/*.h
tests: FORCE
clang-format --style=file -i ./tests/main/unt/*.c ./tests/*.c
FORCE:
+189 -120
View File
@@ -1,78 +1,203 @@
# C Macro Collections
<p align="center">
<img src="https://leoven.github.io/C-Macro-Collections/images/logo.png" alt="C Macro Collections Logo" width="300"/>
<img src="https://leoven.github.io/C-Macro-Collections/img/logo.png" alt="C Macro Collections Logo" width="300"/>
</p>
<p align="center">Header only, macro generated, generic and type-safe Collections in C.</p>
<p align="center">Easy to use, header only, macro generated, generic and type-safe Data Structures in C.</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections"><img src="https://img.shields.io/badge/GitHub-C%20Macro%20Collections-lightgrey.svg?logo=github" alt="LinkToRepo"/></a>
<a href="https://leoven.github.io/C-Macro-Collections/"><img style="color: #ffffff;" src="https://img.shields.io/badge/Read%20the%20Docs-5A5A5A.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHN0eWxlPSIiPjxyZWN0IGlkPSJiYWNrZ3JvdW5kcmVjdCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgeD0iMCIgeT0iMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJub25lIi8%2BPHRpdGxlPmljbi9kb2MtdGV4dDwvdGl0bGU%2BPGcgY2xhc3M9ImN1cnJlbnRMYXllciIgc3R5bGU9IiI%2BPHRpdGxlPkxheWVyIDE8L3RpdGxlPjxwYXRoIGQ9Ik01IDFoNC4yNDRhMiAyIDAgMCAxIDEuNDM0LjYwNmwyLjc1NiAyLjgzNEEyIDIgMCAwIDEgMTQgNS44MzVWMTJhMyAzIDAgMCAxLTMgM0g1YTMgMyAwIDAgMS0zLTNWNGEzIDMgMCAwIDEgMy0zem0wIDJhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjUuODM1TDkuMjQ0IDNINXptMS41IDdoM2EuNS41IDAgMSAxIDAgMWgtM2EuNS41IDAgMSAxIDAtMXptMC0yaDJhLjUuNSAwIDAgMSAwIDFoLTJhLjUuNSAwIDAgMSAwLTF6TTggMmwzIDEuOTk1TDEzIDdIOWExIDEgMCAwIDEtMS0xVjJ6IiBpZD0iYSIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8%2BPC9nPjwvc3ZnPg%3D%3D" alt="LinkToDocs"/></a>
<a href="https://github.com/LeoVen/C-Macro-Collections"><img src="https://img.shields.io/badge/GitHub-C%20Macro%20Collections-2195F3.svg?logo=github" alt="LinkToRepo"/></a>
<a href="https://leoven.github.io/C-Macro-Collections/"><img style="color: #ffffff;" src="https://img.shields.io/badge/Read%20the%20Docs-D13636.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHN0eWxlPSIiPjxyZWN0IGlkPSJiYWNrZ3JvdW5kcmVjdCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgeD0iMCIgeT0iMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJub25lIi8%2BPHRpdGxlPmljbi9kb2MtdGV4dDwvdGl0bGU%2BPGcgY2xhc3M9ImN1cnJlbnRMYXllciIgc3R5bGU9IiI%2BPHRpdGxlPkxheWVyIDE8L3RpdGxlPjxwYXRoIGQ9Ik01IDFoNC4yNDRhMiAyIDAgMCAxIDEuNDM0LjYwNmwyLjc1NiAyLjgzNEEyIDIgMCAwIDEgMTQgNS44MzVWMTJhMyAzIDAgMCAxLTMgM0g1YTMgMyAwIDAgMS0zLTNWNGEzIDMgMCAwIDEgMy0zem0wIDJhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjUuODM1TDkuMjQ0IDNINXptMS41IDdoM2EuNS41IDAgMSAxIDAgMWgtM2EuNS41IDAgMSAxIDAtMXptMC0yaDJhLjUuNSAwIDAgMSAwIDFoLTJhLjUuNSAwIDAgMSAwLTF6TTggMmwzIDEuOTk1TDEzIDdIOWExIDEgMCAwIDEtMS0xVjJ6IiBpZD0iYSIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8%2BPC9nPjwvc3ZnPg%3D%3D" alt="LinkToDocs"/></a>
</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"/></a>
<a href="#"><img src="https://img.shields.io/badge/Version-v1.8.0-orange.svg" alt="Version"/></a>
<img src="https://img.shields.io/badge/Version-v0.24.0-orange.svg" alt="Version"/>
<a href="https://travis-ci.org/LeoVen/C-Macro-Collections"><img src="https://travis-ci.org/LeoVen/C-Macro-Collections.svg?branch=master" alt="travis-ci"/></a>
<a href="https://codecov.io/gh/LeoVen/C-Macro-Collections"><img src="https://codecov.io/gh/LeoVen/C-Macro-Collections/branch/master/graph/badge.svg" alt="codecov"/></a>
<img src="https://github.com/LeoVen/C-Macro-Collections/workflows/Test%20Suit/badge.svg?branch=master" alt="test_suit"/>
</p>
## Table of Contents
* Project Structure
* Available Collections
* Features
* Overall To-Do
* Design Decisions
* What to use
* How to use
* [Installation](#installation)
* [Contributing](#contributing)
* [Usage](#usage)
* [Features](#features)
* [Project Structure](#project-structure)
* [Available Collections](#available-collections)
* [Other Features](#other-features)
* [Design Decisions](#design-decisions)
* [What to use](#what-to-use)
* [Code Review](#code-review)
## Installation
No installation is required. The entire library is made of header files and can be directly included into your project.
## Contributing
There is a lot to be done. You can check the `TODO` file in the root of the repository or the issues in the github page. Also, tests and documentation are in constant development. Also check out the `STATUS` file for the status on the development of the library.
## Usage
The header `macro_collections.h` includes every feature from the library and comes with higher level APIs that help you generate collections from specific sub-libraries with specific extensions.
Below is a minimal example that makes use of some core functionalities. And a lot of explanation too!
```c
// This is the master header. This will include every feature of the library.
// This comes with many helper macros (high level API) and utility functions.
#include "macro_collections.h"
// A PARAM is a standard way to pass required parameters to the lower level API.
// It is a tuple of form (PFX, SNAME, SIZE, K, V). In this case, not all of them
// are used, so we can leave them empty. We are creating a list of value int.
#define MY_LIST_PARAMS (intl, int_list, , , int)
// High level API. Generate a LIST from the CMC library with the STR extension
// using our previously defined PARAMs. Every collections has a CORE part that
// needs to be generated first. Then, we can add other parts after. This macro
// does all of that for us. The STR part will provide us with a function that
// will be used later.
C_MACRO_COLLECTIONS_GEN(CMC, LIST, MY_LIST_PARAMS, (STR))
int main(void)
{
// Our list type is defined by SNAME and all functions are prefixed by PFX
// (PFX can also be thought as the function's namespace). Also, nodes,
// entries, iterators and other structures are prefixed by SNAME. So PFX is
// for functions and SNAME is for structs, where the main one is simply
// 'struct SNAME'.
// To initialize a list we need to pass in an initial capacity and something
// that is called a function table for the V type.
// This function table is a struct with methods that will extract some
// (sometimes) necessary behaviour from your custom data type. Things like
// hash, comparison and printing. A list doesn't require any of these
// functions. That is, the CORE module doesn't use any of them.
// But since we are using the STR module, we will need to define the 'str'
// function. luckily, for the 'int' type, the library already provides such
// function (cmc_i32_str), provided by the /utl/futils.h header file.
struct int_list *list = intl_new(32, &(struct int_list_fval){ .str = cmc_i32_str, NULL });
// Check if the list was successfully initialized. It could fail if the
// initial capacity is too big or if 'struct int_list_fval *' is NULL,
// because every data structure must have a valid function table.
if (!list)
return 1;
// Add some items to the list. The CMC data structures are all dynamically
// sized. So there can be as many items as you want as long as you have
// enough memory.
for (int i = 0; i < 100; i++)
{
// Try to add an element to the list. If it fails you can check what
// caused it by getting its flag.
if (!intl_push_back(list, i))
{
enum cmc_flags flag = intl_flag(list);
// Use cmc_flags_to_str to map the enum error to a string.
fprintf(stderr, "%s : push_back failed\n", cmc_flags_to_str[flag]);
}
}
// Now we will use the STR module, the _print() function. This is where the
// '.str' from the function table comes into play. If we haven't defined it,
// the program would've crashed. We also need to define to which file we
// will be printing the list's content. In this case, the terminal. Also,
// some strings need to be defined. They will be printed: before all elements,
// between each one, and after all elements. This is very usefull and can
// print a data structure very nicely.
intl_print(list, stdout, "[ ", ", ", " ]\n");
// You should see a nicely printed list in your terminal.
// Free all of its resources
intl_free(list);
}
```
Now all you have to do is to compile the source code with `-I /path/to/library/src`. There is no required installation or pre-compilation.
## Features
The C Macro Collections library is organized into many other sub-libraries. The following table is a quick overview.
| Library | Name | Description |
| :-----: | -------------------------------- | ------------------------------------------------------------------------------------------- |
| CMC | Macro Collections | The main library with dynamically-sized collections |
| COR | Core | Core functionalities used by more than one collection, usually from different sub-libraries |
| EXT | Extensions | Extension to collections from CMC, SAC and TSC libraries |
| INT | Integrations | Macros that facilitate the creation of code that involves more than one type of collection |
| SAC | Statically Allocated Collections | Collections with a fixed sized array that don't use any heap allocation |
| TSC | Thread-Safe Collections | Collections that allow multiple operations from multiple threads |
| UTL | Utilities | General utilities |
Every macro that generates code for a certain collection can be found with the following template. Some exceptions exist as certain collections don't have or can't have some features. One big example is the `UTL` library, which does not follow this pattern.
```
macro_name := CMC_[ lib ]_[ collection ]_[ part ]_[ file ]
lib := CMC | COR | DEV | EXT | INT | SAC | TSC
collection := BITSET | DEQUE | HASHBIDIMAP | ... | TREEMULTISET | TREESET
part := CORE | ITER | INIT | ... | SETF | NODE
file := HEADER | SOURCE
```
__Some `collection`s might not be present in a certain `lib`. Check the documentation.__
Every macro is suffixed by `CMC` and each section is separated by an underscore (`_`). The first section is the library (`lib`). The second is the collection name in all uppercase. Then the `part` (or which module) that you wish to generate. And last, if it is code that should belong to a header file or code that should belong to a source file.
## Project Structure
* __benchmarks__ - Where all benchmarks are hosted
* __docs__ - A folder hosting the generated documentation by [Slate](https://github.com/slatedocs/slate)
* __documentation__ - Backup folder of the markdowns and custom styles used in [Slate](https://github.com/slatedocs/slate)
* __docs__ - A folder hosting the generated documentation by [mdBook](https://github.com/rust-lang/mdBook)
* __documentation__ - The markdowns used by [mdBook](https://github.com/rust-lang/mdBook) to generate the website
* __examples__ - Examples using the C Macro Collections Library
* __src__ - All headers part of the C Macro Collections Library
* __cmc__ - The main C Macro Collections Library
* __cor__ - Core includes in the C Macro Collections Library
* __dev__ - The main C Macro Collections Library for development (containing logging)
* __sac__ - Statically Allocated Collections
* __utl__ - Utility like ForEach macros, logging, etc
* __ext__ - Extensions to the CMC, SAC and TSC collections
* __int__ - Integrations between Collections
* __sac__ - Statically Allocated Collections
* __tsc__ - Thread Safe Collections
* __utl__ - Utilities like ForEach macros, logging, etc
* __macro\_collections.h__ - Master header containing all collections and utilities
* __tests__ - Where all tests are hosted
## Available Collections
* Linear Collections
* List, LinkedList, Deque, Stack, Queue, SortedList
* Sets
* HashSet, TreeSet, MultiSet
* Maps
* BidiMap, HashMap, TreeMap, MultiMap
* Heaps
* Heap, IntervalHeap
Check out the STATUS file at the root of the project for more information.
| Collection <img width=250/> | Abstract Data Type <img width=250/> | Data Structure <img width=250/> | Details |
| :--------------------------------: | :---------------------------------: | :-----------------------------: | :-----------------------------------: |
| BidiMap <br> _bidimap.h_ | Bidirectional Map | Two Hashtables | A bijection between two sets of unique keys and unique values `K <-> V` using two hashtables |
| Deque <br> _deque.h_ | Double-Ended Queue | Dynamic Circular Array | A circular array that allows `push` and `pop` on both ends (only) at constant time |
| HashMap <br> _hashmap.h_ | Map | Hashtable | A unique set of keys associated with a value `K -> V` with constant time look up using a hashtable with open addressing and robin hood hashing |
| HashSet <br> _hashset.h_ | Set | Hashtable | A unique set of values with constant time look up using a hashtable with open addressing and robin hood hashing |
| Heap <br> _heap.h_ | Priority Queue | Dynamic Array | A binary heap as a dynamic array as an implicit data structure |
| IntervalHeap <br> _intervalheap.h_ | Double-Ended Priority Queue | Custom Dynamic Array | A dynamic array of nodes, each hosting one value from the MinHeap and one from the MaxHeap |
| LinkedList <br> _linkedlist.h_ | List | Doubly-Linked List | A default doubly-linked list |
| List <br> _list.h_ | List | Dynamic Array | A dynamic array with `push` and `pop` anywhere on the array |
| MultiMap <br> _multimap.h_ | Multimap | Custom Hashtable | A mapping of multiple keys with one node per key using a hashtable with separate chaining |
| Multiset <br> _multiset.h_ | Multiset | Hashtable | A mapping of a value and its multiplicity using a hashtable with open addressing and robin hood hashing |
| Queue <br> _queue.h_ | FIFO | Dynamic Circular Array | A queue using a circular array with `enqueue` at the `back` index and `dequeue` at the `front` index |
| SortedList <br> _sortedlist.h_ | Sorted List | Sorted Dynamic Array | A lazily sorted dynamic array that is sorted only when necessary |
| Stack <br> _stack.h_ | FILO | Dynamic Array | A stack with push and pop at the end of a dynamic array |
| TreeMap <br> _treemap.h_ | Sorted Map | AVL Tree | A unique set of keys associated with a value `K -> V` using an AVL tree with `log(n)` look up and sorted iteration |
| TreeSet <br> _treeset.h_ | Sorted Set | AVL Tree | A unique set of keys using an AVL tree with `log(n)` look up and sorted iteration |
__The following table is an overview of all the currently available or upcoming data structures__:
## Features
| Collection <img width=250/> | Abstract Data Type <img width=250/> | Data Structure <img width=250/> | Details |
| :--------------------------------: | :---------------------------------: | :-----------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------: |
| BitSet <br> _bitset.h_ | Set | Dynamic Array | A set of bits that can be individually modified and queried, each identified by a bit index |
| Deque <br> _deque.h_ | Double-Ended Queue | Dynamic Circular Array | A circular array that allows `push` and `pop` on both ends (only) at constant time |
| HashBidiMap <br> _hashbidimap.h_ | Bidirectional Map | Two Hashtables | A bijection between two sets of unique keys and unique values `K <-> V` using two hashtables |
| HashMap <br> _hashmap.h_ | Map | Flat Hashtable | A unique set of keys associated with a value `K -> V` with constant time look up using a hashtable with open addressing and robin hood hashing |
| HashMultiMap <br> _hashmultimap.h_ | Multimap | Hashtable | A mapping of multiple keys with one node per key using a hashtable with separate chaining |
| HashMultiSet <br> _hashmultiset.h_ | Multiset | Flat Hashtable | A mapping of a value and its multiplicity using a hashtable with open addressing and robin hood hashing |
| HashSet <br> _hashset.h_ | Set | Flat Hashtable | A unique set of values with constant time look up using a hashtable with open addressing and robin hood hashing |
| Heap <br> _heap.h_ | Priority Queue | Dynamic Array | A binary heap as a dynamic array as an implicit data structure |
| IntervalHeap <br> _intervalheap.h_ | Double-Ended Priority Queue | Custom Dynamic Array | A dynamic array of nodes, each hosting one value from the MinHeap and one from the MaxHeap |
| LinkedList <br> _linkedlist.h_ | List | Doubly-Linked List | A default doubly-linked list |
| List <br> _list.h_ | List | Dynamic Array | A dynamic array with `push` and `pop` anywhere on the array |
| Queue <br> _queue.h_ | FIFO | Dynamic Circular Array | A queue using a circular array with `enqueue` at the `back` index and `dequeue` at the `front` index |
| SkipList <br> _WIP_ | Sorted List | Skip List | A sorted Linked List with average O(log n) search, insertion and deletion complexity |
| SortedList <br> _sortedlist.h_ | Sorted List | Sorted Dynamic Array | A lazily sorted dynamic array that is sorted only when necessary |
| Stack <br> _stack.h_ | FILO | Dynamic Array | A stack with push and pop at the end of a dynamic array |
| TreeBidiMap <br> _WIP_ | Sorted Bidirectional Map | Two AVL Trees | A sorted bijection between two sets of unique keys and unique values `K <-> V` using two AVL trees |
| TreeMap <br> _treemap.h_ | Sorted Map | AVL Tree | A unique set of keys associated with a value `K -> V` using an AVL tree with `log(n)` look up and sorted iteration |
| TreeMultiMap <br> _WIP_ | Sorted Multimap | AVL Tree | A sorted mapping of multiple keys with one node per key using an AVL Tree of linked-lists |
| TreeMultiSet <br> _WIP_ | Sorted Multiset | AVL Tree | A sorted mapping of a value and its multiplicity using an AVL tree |
| TreeSet <br> _treeset.h_ | Sorted Set | AVL Tree | A unique set of keys using an AVL tree with `log(n)` look up and sorted iteration |
## Other Features
These are some features within the library that are implemented by all collections.
### Two-way iterators
@@ -124,41 +249,31 @@ A priority function works much like the comparator function except that it compa
The following table shows which functions are required, optional or never used for each Collection:
| Collection | CMP | CPY | STR | FREE | HASH | PRI |
| ---------- | :-: | :-: | :-: | :--: | :--: | :-: |
| BidiMap | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| Collection | CMP | CPY | STR | FREE | HASH | PRI |
| ------------ | :------------------------------------------------------: | :------------------------------------------------------: | :------------------------------------------------------: | :------------------------------------------------------: | :------------------------------------------------------: | :------------------------------------------------------: |
| Deque | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| HashMap | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| HashBidiMap | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| HashMultiMap | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| HashMultiSet | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| HashSet | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| Heap | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) |
| IntervalHeap | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) |
| List | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| LinkedList | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| MultiMap | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| MultiSet | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| Queue | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| SortedList | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| Stack | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| TreeMap | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| TreeSet | ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
| Color | Label |
| :---: | ----- |
| ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | Required for basic functionality. |
| ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | Required for specific functions. |
| Color | Label |
| :------------------------------------------------------: | ----------------------------------------- |
| ![#b82b28](https://placehold.it/20/b82b28/000000?text=+) | Required for basic functionality. |
| ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | Required for specific functions. |
| ![#497edd](https://placehold.it/20/497edd/000000?text=+) | Required for non-core specific functions. |
| ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | Optional. |
| ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | Not Used. |
## Overall To-Do
In the long term, these are the steps left for the completion of this library:
* Complete the implementation of all the functions in the scope of the TODO file for the main collections;
* Reorganize and complete all tests for the `cmc` collections;
* Make an exact copy of all collections to `dev` with many logging utility, for them to be used under development;
* Port all of these collections to be statically allocated and be part of the `sac` library;
* Complete all tests for `sac`.
| ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | Optional. |
| ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | Not Used. |
## Design Decisions
@@ -186,6 +301,8 @@ Modifying a collection will possibly invalidate all iterators currently initiali
## What to use
(Outdated)
The following table shows how each collection is implemented and how well they do when using as common [abstract data types](https://en.wikipedia.org/wiki/Abstract_data_type).
* **Ideal** - The collection implements correctly the abstract data type;
@@ -198,62 +315,14 @@ The following table shows how each collection is implemented and how well they d
![AverageColor](https://img.shields.io/badge/Not_Ideal_Implementation-%2363a4ff.svg)
![BadColor](https://img.shields.io/badge/Bad_Implementation-%23ff6659.svg)
## How to use
## Code Review
To generate the collection, all you need to do is to include the necessary header files. You can include the containers you want to use individually or you can include the master header, `macro_collections.h`, that comes with the entire C-Macro-Collections library.
Check out some code reviews that covers some parts the project. Most of them were posted a long time ago and are probably outdated.
### Macros
> Note here that `SNAME` represents the uppercase name of the collection.
Every collection is separated by two parts:
* `HEADER` - Contains all struct definitions and function definitions.
* `SOURCE` - Contains all function implementations.
All collections have three main macros:
* `CMC_GENERATE_SNAME` - Generates `CMC_GENERATE_SNAME_HEADER` and `CMC_GENERATE_SNAME_SOURCE`.
Or you can generate each part individually:
* `CMC_GENERATE_SNAME_HEADER` - Generates all struct definitions and function definitions.
* `CMC_GENERATE_SNAME_SOURCE` - Generates all function implementations.
### Parameters
When including `macro_collections.h` in your source code you gain access to a macro called `CMC_COLLECTION_GENERATE` with the following parameters:
* __C__ - Container name in uppercase (*BIDIMAP*, *DEQUE*, *HASHMAP*, *HASHSET*, *HEAP*, *INTERVALHEAP*, *LINKEDLIST*, *LIST*, *MULTIMAP*, *MULTISET*, *QUEUE*, *SORTEDLIST*, *STACK*, *TREEMAP*, *TREESET*).
* __PFX__ - Functions prefix or namespace.
* __SNAME__ - Structure name (`struct SNAME`).
* __K__ - Key type. Only used in *HASHMAP*, *TREEMAP*, *MULTIMAP* and *BIDIMAP*; ignored by others.
* __V__ - Value type. Primary type for most collections, or value to be mapped by *HASHMAP*, *TREEMAP*, *MULTIMAP* and *BIDIMAP*.
**In fact, all macros follow this pattern.** So whenever you see a macro with a bunch of parameters and you don't know what they are, you can check out the above list.
### For Each
There are 2 for-each macros:
* `CMC_FOREACH` - Starts at the start of the collection towards the end.
* `CMC_FOREACH_REV` - Starts at the end of the collection towards the start.
* __PFX__ - Functions prefix or namespace.
* __SNAME__ - Structure name.
* __TARGET__ - The variable name of the collection you wish to iterate over.
* __ITERNAME__ - Iterator variable name.
For `CMC_FOREACH` and `CMC_FOREACH_REV` you will be able to name the iterator variable through the __ITERNAME__ parameter.
<hr>
Check out some code reviews that covers some parts the project:
| About | Link |
|-------|--------|
| Unit Test *./utl/test.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=222954)](http://codereview.stackexchange.com/q/222954/178948) |
| About | Link |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| Unit Test *./utl/test.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=222954)](http://codereview.stackexchange.com/q/222954/178948) |
| Interval Heap *./cmc/intervalheap.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=223595)](http://codereview.stackexchange.com/q/223595/178948) |
| Hash Set *./cmc/hashset.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=217333)](http://codereview.stackexchange.com/q/217333/178948) |
| Linked List *./cmc/linkedlist.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=216737)](http://codereview.stackexchange.com/q/216737/178948) |
| Others | [![Code Review](http://www.zomis.net/codereview/shield/?qid=213553)](http://codereview.stackexchange.com/q/213553/178948) |
| Hash Set *./cmc/hashset.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=217333)](http://codereview.stackexchange.com/q/217333/178948) |
| Linked List *./cmc/linkedlist.h* | [![Code Review](http://www.zomis.net/codereview/shield/?qid=216737)](http://codereview.stackexchange.com/q/216737/178948) |
| Others | [![Code Review](http://www.zomis.net/codereview/shield/?qid=213553)](http://codereview.stackexchange.com/q/213553/178948) |
+72
View File
@@ -0,0 +1,72 @@
Approximate completion of the library
[ 99 ][ 99 ][ 99 ] %
[source][tests][docs]
## - Finished
[30][15][01] Library
[91][45][01] CMC
[40][40][05] BitSet
[##][##][10] Deque
[80][70][00] HashBidiMap
[##][##][00] HashMap
[##][20][00] HashMultiMap
[##][20][00] HashMultiSet
[##][40][00] HashSet
[##][30][00] Heap
[##][40][00] IntervalHeap
[90][20][00] LinkedList
[90][30][00] List
[##][60][00] Queue
[00][00][00] SkipList
[80][20][00] SortedList
[95][90][00] Stack
[00][00][00] TreeBidiMap
[95][20][00] TreeMap
[00][00][00] TreeMultiMap
[00][00][00] TreeMultiSet
[95][20][00] TreeSet
[00][00][00] SAC
[00][00][00] BitSet
[00][00][00] Deque
[00][00][00] HashBidiMap
[00][00][00] HashMap
[00][00][00] HashMultiMap
[00][00][00] HashMultiSet
[00][00][00] HashSet
[00][00][00] Heap
[00][00][00] IntervalHeap
[00][00][00] LinkedList
[00][00][00] List
[00][00][00] Queue
[00][00][00] SkipList
[00][00][00] SortedList
[00][00][00] Stack
[00][00][00] TreeBidiMap
[00][00][00] TreeMap
[00][00][00] TreeMultiMap
[00][00][00] TreeMultiSet
[00][00][00] TreeSet
[00][00][00] TSC
[00][00][00] BitSet
[00][00][00] Deque
[00][00][00] HashBidiMap
[00][00][00] HashMap
[00][00][00] HashMultiMap
[00][00][00] HashMultiSet
[00][00][00] HashSet
[00][00][00] Heap
[00][00][00] IntervalHeap
[00][00][00] LinkedList
[00][00][00] List
[00][00][00] Queue
[00][00][00] SkipList
[00][00][00] SortedList
[00][00][00] Stack
[00][00][00] TreeBidiMap
[00][00][00] TreeMap
[00][00][00] TreeMultiMap
[00][00][00] TreeMultiSet
[00][00][00] TreeSet
+54 -12
View File
@@ -1,19 +1,57 @@
TODO
Patch - Changes that can be released by a patch version
Minor - Changes that require a bit more time than a simple patch
Major - 1.0.0 version or breaking changes
The library follows https://semver.org/
Check out CHANGELOG
[/] - In Progress
[X] - Finished
#!! High Priority ----------------------------------------------------------------------------------
[/] Tests
[/] Documentation
#!! Next Patch -----------------------------------------------------------------
#!! Medium Priority --------------------------------------------------------------------------------
[ ] Fix BitSet, using capacity vs. counter
[ ] #12 - Fix the collections that depend on ITER
#!! Major ----------------------------------------------------------------------
[ ] Stabilize the library
[ ] Add INT library
[ ] Add SAC library
[ ] Add TSC library
[ ] Separate inner Data Structure implementation from the Collection's one
[ ] CMC_NAMES - Full customization of function names (see CMC_CAMEL_CASE)
[\] Tests
[\] Documentation
#!! Minor ----------------------------------------------------------------------
[ ] #13 - Properly implement HashBidiMap iterator
[ ] #10 - Fix Benchmarks and Examples
[ ] More SortedList functions
[ ] BidiMap's _is_mapping() to check if a mapping K <=> V exists
[ ] New asserts - _array_int(), _array_not_in() and str
[ ] Add Stack's _peek() and _top() (get by value, get by pointer)
[ ] CMC_TIMED for timed blocks
[ ] _iter_at() iterator
#!! Patch ----------------------------------------------------------------------
[ ] MultiSets replace existing value with the new added one
[ ] Fix PUBLIC and PRIVATE incompatibility between CMC and EXT
#!! Considerations -------------------------------------------------------------
[ ] rand.h utility
[ ] Redo `while (true)` in hashtables' _insert()
[ ] Add to_array and from_array functions
#!! Being Considered -------------------------------------------------------------------------------
[ ] Serialization
[ ] save {all}
[ ] load {all}
@@ -22,13 +60,14 @@ TODO
[ ] Zip Iterators
[ ] Consumer Iterators
#!! Optimizations ----------------------------------------------------------------------------------
[ ] Use binary search to find optimum hashtable prime size inside impl_calculate_size
[ ] Optimize certain loops that use iterators that can simply use a normal loop
[ ] Replace IntervalHeap node by a simple buffer of two pointers (V (*buffer)[2])
#!! Optimizations --------------------------------------------------------------
#!! Done -------------------------------------------------------------------------------------------
[ ] Use binary search to find optimum hashtable prime size inside
impl_calculate_size
#!! Done -----------------------------------------------------------------------
[X] Remove PUBLIC and PRIVATE
[X] Utility
@@ -62,3 +101,6 @@ TODO
[X] Merge bidirectional map key_buffer and val_buffer to a single buffer and make key_dist and val_dist into dist[2]
[X] Callback utility
on_create, on_read, on_update, on_delete, on_resize
[X] Replace IntervalHeap node by a simple buffer of two pointers (V (*buffer)[2])
[X] PUBLIC and PRIVATE is back (opaque data structures)
[X] Add EXT library
+432
View File
@@ -0,0 +1,432 @@
# A script that automatically generates code for code coverage, updates tests
# and Makefiles, and creates necessary directories
import argparse
import os
import pathlib
import re
import shutil
import subprocess
import sys
from typing import List, Text
# Config Script Configuration
# Directories Names for directories
# Output Where the outputted code is to be put
# Build Where the build objects are to be located
# Compiler Compiler Configurations
# Compilation Tests, code coverage and flags
# Macro Expansion Configuration for the code expansion
# Collections All collections
#
# Variables marked as const are to not be modified
# Directories
# Output directory
# In this directory it is assumed that the following files and directories are
# included: main.c, unt folder
OUTPUT_DIR = './tests'
# All libraries
ALL_LIBS = ['CMC']
# Directory mapping
DIR_MAP = {'HEADER': 'include', 'SOURCE': 'src'}
# File extension mapping
EXT_MAP = {'HEADER': 'h', 'SOURCE': 'c'}
# Where compilation objects will be outputted
BUILD_DIR = f'{OUTPUT_DIR}/build'
# const
INCLUDE_DIR = f"{OUTPUT_DIR}/{DIR_MAP['HEADER']}"
# const
SRC_DIR = f"{OUTPUT_DIR}/{DIR_MAP['SOURCE']}"
# Where object files .o go
OBJ_DIR = BUILD_DIR
# The name of the main test executable
TEST_EXE = f'{OUTPUT_DIR}/main.exe'
# Where .gcov files should go
GCOV_DIR = f'{BUILD_DIR}/gcov'
# Compiler
# Compilation
CC = 'gcc'
# Compilation Flags
CFLAGS = ['-Wall', '-Werror']
# Link flags
LFLAGS = []
# Coverage Flags
CVFLAGS = ['--coverage', '-O0']
# gcov flags
GCOV_FLAGS = []
# Include to the main Library
# const
INCLUDE = ['-I', './src']
# Include to the test file headers
# const
TINCLUDE = ['-I', f'{INCLUDE_DIR}']
# Macro expansion
# -E Only preprocessor
# -P No linemarkers
# -C Keep comments, except those inside macros (for UNIQUE_FLAG)
# const
EXPAND_FLAGS = '-E -P -C'
# Used to delimiter where the actual code starts and ends. Used by regex.
# Needs to be a valid C comment.
UNIQUE_FLAG = '// C_MACRO_COLLECTIONS_CODE'
# Temporary file used to expand the macros
TMP_FILE = './main.c'
# Just a realy helpfull overview
CONFIG = f'''Directory Settings
OUTPUT_DIR = {OUTPUT_DIR}
ALL_LIBS = {ALL_LIBS}
DIR_MAP = {DIR_MAP}
EXT_MAP = {EXT_MAP}
BUILD_DIR = {BUILD_DIR}
INCLUDE_DIR = {INCLUDE_DIR}
SRC_DIR = {SRC_DIR}
OBJ_DIR = {OBJ_DIR}
GCOV_DIR = {GCOV_DIR}
Compiler Settings
CC = {CC}
CFLAGS = {CFLAGS}
LFLAGS = {LFLAGS}
CVFLAGS = {CVFLAGS}
GCOV_FLAGS = {GCOV_FLAGS}
INCLUDE = {INCLUDE}
TINCLUDE = {TINCLUDE}
Macro Expansion
EXPAND_FLAGS = {EXPAND_FLAGS}
UNIQUE_FLAG = {UNIQUE_FLAG}
TMP_FILE = {TMP_FILE}'''
# All collections that can be used for testing
COLLECTIONS = [
# header, library, collection, pfx, sname, size, key, val
{'h': '"cmc/bitset.h"', 'LIB': 'CMC', 'COLLECTION': 'BITSET', 'PFX': 'bs', 'SNAME': 'bitset', 'SIZE': '', 'K': '', 'V': '' },
{'h': '"cmc/deque.h"', 'LIB': 'CMC', 'COLLECTION': 'DEQUE', 'PFX': 'd', 'SNAME': 'deque', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/hashbidimap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHBIDIMAP', 'PFX': 'hbm', 'SNAME': 'hashbidimap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
{'h': '"cmc/hashmap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMAP', 'PFX': 'hm', 'SNAME': 'hashmap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
{'h': '"cmc/hashmultimap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMULTIMAP', 'PFX': 'hmm', 'SNAME': 'hashmultimap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
{'h': '"cmc/hashmultiset.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMULTISET', 'PFX': 'hms', 'SNAME': 'hashmultiset', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/hashset.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHSET', 'PFX': 'hs', 'SNAME': 'hashset', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/heap.h"', 'LIB': 'CMC', 'COLLECTION': 'HEAP', 'PFX': 'h', 'SNAME': 'heap', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/intervalheap.h"', 'LIB': 'CMC', 'COLLECTION': 'INTERVALHEAP', 'PFX': 'ih', 'SNAME': 'intervalheap', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/linkedlist.h"', 'LIB': 'CMC', 'COLLECTION': 'LINKEDLIST', 'PFX': 'll', 'SNAME': 'linkedlist', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/list.h"', 'LIB': 'CMC', 'COLLECTION': 'LIST', 'PFX': 'l', 'SNAME': 'list', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/queue.h"', 'LIB': 'CMC', 'COLLECTION': 'QUEUE', 'PFX': 'q', 'SNAME': 'queue', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/sortedlist.h"', 'LIB': 'CMC', 'COLLECTION': 'SORTEDLIST', 'PFX': 'sl', 'SNAME': 'sortedlist', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/stack.h"', 'LIB': 'CMC', 'COLLECTION': 'STACK', 'PFX': 's', 'SNAME': 'stack', 'SIZE': '', 'K': '', 'V': 'size_t'},
{'h': '"cmc/treemap.h"', 'LIB': 'CMC', 'COLLECTION': 'TREEMAP', 'PFX': 'tm', 'SNAME': 'treemap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
{'h': '"cmc/treeset.h"', 'LIB': 'CMC', 'COLLECTION': 'TREESET', 'PFX': 'ts', 'SNAME': 'treeset', 'SIZE': '', 'K': '', 'V': 'size_t'}
]
def full_path(path: Text) -> Text:
'''
Returns the full path of a 'path' with ralative paths, e.g. './' or '../'
'''
return str(pathlib.Path(path).resolve())
def execute_command(commands: List[Text]):
cmd = ' '.join(commands)
print(cmd)
subprocess.check_call(cmd, shell=True)
# if cp.returncode != 0:
# print('Error when executing the last command')
# exit(1)
def assert_executable(program: Text):
'''
Asserts that a given program is installed and available in PATH.
'''
if shutil.which(program) is None:
raise Exception(f'The required executable {program} was not found in your path')
def assert_dir(directory: Text):
'''
Given a string 'directory' that is a path to a directory, make sure that it exists.
'''
if not os.path.exists(directory):
os.makedirs(directory)
def assert_structure():
'''
Git might not commit some required directories. This function asserts that they exist.
'''
assert_dir(OUTPUT_DIR)
# include and src
for directory in DIR_MAP.values():
assert_dir(f'{OUTPUT_DIR}/{directory}')
# For each library, create a directory for include and src
for lib in ALL_LIBS:
for directory in DIR_MAP.values():
assert_dir(f'{OUTPUT_DIR}/{directory}/{lib.lower()}')
assert_dir(BUILD_DIR)
assert_dir(OBJ_DIR)
assert_dir(GCOV_DIR)
for lib in ALL_LIBS:
assert_dir(f'{OBJ_DIR}/{lib.lower()}')
def clean_build(cleanfull: bool):
'''
Removes all files generated by compilation and code coverage along with folders.
'''
# -f prevents 'rm' from failing
execute_command(['rm', '-r', '-f', f'{GCOV_DIR}/*.gcov'])
execute_command(['rm', '-f', TEST_EXE])
execute_command(['rm', '-r', '-f', BUILD_DIR])
if cleanfull:
execute_command(['rm', '-r', SRC_DIR])
execute_command(['rm', '-r', INCLUDE_DIR])
def expand_code():
'''
Expands code to be used in tests. This is necessary because code coverage doesn't work with macros.
'''
# Generate Header and Source separately
for ftype in ['HEADER', 'SOURCE']:
for data in COLLECTIONS:
file = open(TMP_FILE, 'w')
file.write(
f'''
#include "macro_collections.h"
{UNIQUE_FLAG}
C_MACRO_COLLECTIONS_ALL_{ftype}({data['LIB']}, {data['COLLECTION']}, ({', '.join([data['PFX'], data['SNAME'], data['SIZE'], data['K'], data['V']])}))
{UNIQUE_FLAG}
''')
file.flush()
file.close()
result = subprocess.getoutput(f'{CC} {EXPAND_FLAGS} {" ".join(INCLUDE)} {TMP_FILE}')
# (?s) makes '.' match anything, even '\n'
match = re.search(fr'(?s){UNIQUE_FLAG}(?P<code>.+){UNIQUE_FLAG}', result)
if match is None:
os.remove(TMP_FILE)
print('Didn\'t match FLAG. Probably because compilation failed.', file=sys.stderr)
exit(1)
file = open(f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/{data["LIB"].lower()}/{data["SNAME"]}.{EXT_MAP[ftype]}', 'w')
if ftype == 'HEADER':
file.write(
f'''
#ifndef CMC_{data['LIB']}_{data['COLLECTION']}_TEST_H
#define CMC_{data['LIB']}_{data['COLLECTION']}_TEST_H
#include "macro_collections.h"
{match.group('code')}
#endif /* CMC_{data['LIB']}_{data['COLLECTION']}_TEST_H */
''')
else:
file.write(
f'''
#include {data["h"]}
{match.group("code")}
''')
file.flush()
file.close()
print(f'Generated {data["h"]: >20} -> {OUTPUT_DIR}/{DIR_MAP[ftype]}/{data["LIB"].lower()}/{data["SNAME"]}.{EXT_MAP[ftype]}')
os.remove(TMP_FILE)
def format_expand():
'''
Format the files outputted by 'expand_code'.
'''
cmd = ['clang-format', '--style=file', '--verbose', '-i']
dirs_to_format = [f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/{lib.lower()}/*.{EXT_MAP[ftype]}' for ftype in DIR_MAP.keys() for lib in ALL_LIBS]
cmd.extend(dirs_to_format)
execute_command(cmd)
def format_code(source: bool, tests: bool):
'''
Format all source files from the main library or test files.
'''
if source:
execute_command(['find', './src/', '-name', '*.h', '|', 'xargs', 'clang-format', '--style=file', '--verbose', '-i'])
if tests:
execute_command(['find', './tests/', '-name', '*.c', '-o', '-name', '*.h', '|', 'xargs', 'clang-format', '--style=file', '--verbose', '-i'])
def build_tests(with_coverage: bool):
'''
Build all object files and the main executable for tests
'''
cflags = CFLAGS.copy()
if with_coverage:
cflags += CVFLAGS
else:
cflags += ['-O3']
for data in COLLECTIONS:
cmd = [CC]
cmd += cflags
cmd += TINCLUDE # This one needs to go first
cmd += INCLUDE
cmd += ['-c', f"{SRC_DIR}/{data['LIB'].lower()}/{data['SNAME']}.c"]
cmd += ['-o', f"{OBJ_DIR}/{data['LIB'].lower()}/{data['SNAME']}.o"]
execute_command(cmd)
# Build OUTPUT_DIR/main.c
cmd = [CC]
cmd += cflags
cmd += TINCLUDE # This one needs to go first
cmd += INCLUDE
cmd += ['-c', f'{OUTPUT_DIR}/main.c']
cmd += ['-o', f"{OBJ_DIR}/main.o"]
execute_command(cmd)
# Link everything producing OUTPUT_DIR/main.exe
cmd = [CC]
cmd += cflags
cmd += LFLAGS
cmd += ['-o', TEST_EXE]
cmd += [f'{OBJ_DIR}/main.o']
cmd += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.o' for data in COLLECTIONS]
execute_command(cmd)
def run_tests(coverage: bool):
'''
Runs tests. If coverage, run gcov.
'''
execute_command([full_path(TEST_EXE)])
if coverage:
objects = [f'{OBJ_DIR}/main.gcda']
objects += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.gcda' for data in COLLECTIONS]
execute_command(['gcov'] + GCOV_FLAGS + objects)
execute_command(['mv', '*.gcov', GCOV_DIR])
if __name__ == '__main__':
p = argparse.ArgumentParser('autogen.py', usage='%(prog)s [options]')
p.add_argument('-sc', '--show-config',
help='Displays the current configuration',
action='store_true',
dest='config')
tests = p.add_argument_group('tests', 'For dealing with tests')
tests.add_argument('-c', '--clean',
help='Cleans all build objects',
default=False,
action='store_true',
dest='clean')
tests.add_argument('-cf', '--clean-full',
help='Cleans all build objects, source and header files, and removes folders',
default=False,
action='store_true',
dest='cleanfull')
tests.add_argument('-e', '--expand',
help='Expands the header and source files',
default=False,
action='store_true',
dest='expand')
tests.add_argument('-nf', '--no-format',
help='Does not format the output of expand. Can be used when you might not have clang-format',
default=False,
action='store_true',
dest='noformat')
tests.add_argument('-b', '--build',
help='Compile the object files and the main executable',
default=False,
action='store_true',
dest='build')
tests.add_argument('-r', '--run',
help='Runs tests, assuming that it is already built',
default=False,
action='store_true',
dest='run')
tests.add_argument('-cv', '--coverage',
help='Adds the code coverage flags for compilation',
default=False,
action='store_true',
dest='coverage')
tests.add_argument('-rr', '--rerun',
help='Compile the object files again and then run the tests',
default=False,
action='store_true',
dest='rerun')
source = p.add_argument_group('source', 'For dealing with the source files and formatting')
source.add_argument('-fs', '--format-source',
help='Format the source code',
default=False,
action='store_true',
dest='fmt_source')
source.add_argument('-ft', '--format-tests',
help='Format tests files',
default=False,
action='store_true',
dest='fmt_tests')
args = p.parse_args()
if args.config:
print(CONFIG)
exit(0)
if args.clean or args.cleanfull:
clean_build(args.cleanfull)
if not args.cleanfull:
assert_structure()
assert_executable(CC)
if args.expand:
expand_code()
if not args.noformat:
assert_executable('clang-format')
format_expand()
else:
# In case the next task is to build the code from source
# This warning is a very annoying one from gcc
CFLAGS += ['-Wno-misleading-indentation']
if args.fmt_source or args.fmt_tests:
assert_executable('find')
assert_executable('xargs')
format_code(args.fmt_source, args.fmt_tests)
if args.build:
build_tests(args.coverage)
if args.run:
run_tests(args.coverage)
elif args.rerun:
build_tests(args.coverage)
run_tests(args.coverage)
elif args.run:
run_tests(args.coverage)
@@ -0,0 +1,62 @@
#ifndef COUNT
#error "Please define COUNT"
#endif
#include "murmurhash.h"
#include "macro_collections.h"
#include "../../util/twister.c"
CMC_CMC_HASHMAP_CORE(PUBLIC, HEADER, (hm, hashmap, , uint64_t, uint64_t))
CMC_CMC_HASHMAP_CORE(PUBLIC, SOURCE, (hm, hashmap, , uint64_t, uint64_t))
int cmp(uint64_t a, uint64_t b)
{
return (a > b) - (a < b);
}
// size_t hash(uint64_t a)
// {
// size_t x = (size_t)a;
// x = ((x >> 16) ^ x) * 0x45d9f3b;
// x = ((x >> 16) ^ x) * 0x45d9f3b;
// x = (x >> 16) ^ x;
// return x;
// }
size_t hash(uint64_t k)
{
static size_t seed = 211106232532969;
return MurMurHash(&k, sizeof(k), seed);
}
struct hashmap_fkey *fkey = &(struct hashmap_fkey) {
.cmp = cmp,
.hash = hash,
NULL
};
struct hashmap_fval *fval = &(struct hashmap_fval) {
.cmp = cmp,
.hash = hash,
NULL
};
int main(void)
{
mt_state tw;
twist_init(&tw, 50331653);
struct hashmap *map = hm_new(COUNT, 0.6, fkey, fval);
for (uint64_t i = 0; i < COUNT; i++)
{
uint64_t v = twist_uint64(&tw);
hm_insert(map, v, v);
}
hm_free(map);
return 0;
}
@@ -0,0 +1,61 @@
#ifndef COUNT
#error "Please define COUNT"
#endif
#include "murmurhash.h"
#include "macro_collections.h"
#include "../../util/twister.c"
C_MACRO_COLLECTIONS_ALL(CMC, HASHMULTIMAP, (hmm, hashmultimap, , uint64_t, uint64_t))
int cmp(uint64_t a, uint64_t b)
{
return (a > b) - (a < b);
}
// size_t hash(uint64_t a)
// {
// size_t x = (size_t)a;
// x = ((x >> 16) ^ x) * 0x45d9f3b;
// x = ((x >> 16) ^ x) * 0x45d9f3b;
// x = (x >> 16) ^ x;
// return x;
// }
size_t hash(uint64_t k)
{
static size_t seed = 211106232532969;
return MurMurHash(&k, sizeof(k), seed);
}
struct hashmultimap_fkey *fkey = &(struct hashmultimap_fkey) {
.cmp = cmp,
.hash = hash,
NULL
};
struct hashmultimap_fval *fval = &(struct hashmultimap_fval) {
.cmp = cmp,
.hash = hash,
NULL
};
int main(void)
{
mt_state tw;
twist_init(&tw, 50331653);
struct hashmultimap *map = hmm_new(COUNT, 0.6, fkey, fval);
for (uint64_t i = 0; i < COUNT; i++)
{
uint64_t v = twist_uint64(&tw);
hmm_insert(map, v, v);
}
hmm_free(map);
return 0;
}
@@ -0,0 +1,58 @@
// https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/hash_bytes.cc
#ifndef MURMURHASH
#define MURMURHASH
#include <string.h>
inline size_t unaligned_load(const char *p)
{
size_t result;
memcpy(&result, p, sizeof(result));
return result;
}
inline size_t load_bytes(const char *p, int n)
{
size_t result = 0;
--n;
do
{
result = (result << 8) + (unsigned char)(p[n]);
} while (--n >= 0);
return result;
}
inline size_t shift_mix(size_t v)
{
return v ^ (v >> 47);
}
size_t MurMurHash(const void *ptr, size_t len, size_t seed)
{
static const size_t mul = (((size_t)0xc6a4a793UL) << 32UL) + (size_t)0x5bd1e995UL;
const char *const buf = (const char *)(ptr);
// Remove the bytes not divisible by the sizeof(size_t). This
// allows the main loop to process the data as 64-bit integers.
const size_t len_aligned = len & ~(size_t)0x7;
const char *const end = buf + len_aligned;
size_t hash = seed ^ (len * mul);
for (const char *p = buf; p != end; p += 8)
{
const size_t data = shift_mix(unaligned_load(p) * mul) * mul;
hash ^= data;
hash *= mul;
}
if ((len & 0x7) != 0)
{
const size_t data = load_bytes(end, len & 0x7);
hash ^= data;
hash *= mul;
}
hash = shift_mix(hash) * mul;
hash = shift_mix(hash);
return hash;
}
#endif /* MURMURHASH */
@@ -0,0 +1,57 @@
import os
import sys
import time
import subprocess
ITERATIONS = 10
COUNT = 20000000
VERBOSE = False
NL = '\n'
INCLUDE = "../../../src"
CC = 'gcc'
CCPP = 'g++' # LoL
OPT = '-O3'
print(f'Using {CC} compiler')
def execute_command(commands):
print(' '.join(commands))
subprocess.run(commands, shell=True)
# Common args
args = ['-I', INCLUDE, OPT, f'-DCOUNT={COUNT}', '-DCMC_NO_CALLBACKS']
map_args = [CC, 'hashmap.c', '-o', 'hashmap.exe']
mmap_args = [CC, 'hashmultimap.c', '-o', 'hashmultimap.exe']
cpp_args = [CCPP, 'unorderedmap.cpp', '-I', INCLUDE, '-o', 'unorderedmap.exe', OPT, f'-DCOUNT={COUNT}']
map_args.extend(args)
mmap_args.extend(args)
cpp_args.extend(args)
execute_command(map_args)
execute_command(mmap_args)
execute_command(cpp_args)
programs = ['hashmap.exe', 'hashmultimap.exe', 'unorderedmap.exe']
for prog in programs:
total = 0
for i in range(ITERATIONS):
print(f'{i}...', end='')
sys.stdout.flush()
start_time = time.time()
subprocess.run(prog, shell=True)
delta = time.time() - start_time
total += delta
if VERBOSE:
print(f'({delta})')
avg = total / ITERATIONS
print(f'{"" if VERBOSE else NL}{avg} seconds for {COUNT} -> AVG[{int((avg * 1e9) / COUNT)} ns] [{prog}]{NL if VERBOSE else ""}')
@@ -0,0 +1,34 @@
#ifndef COUNT
#error "Please define COUNT"
#endif
#include "murmurhash.h"
#include <unordered_map>
#include "../../util/twister.c"
struct IntHasher
{
std::size_t operator()(const uint64_t& k) const
{
static size_t seed = 211106232532969;
return MurMurHash(&k, sizeof(k), seed);
}
};
int main(void)
{
mt_state tw;
twist_init(&tw, 50331653);
std::unordered_map<uint64_t, uint64_t, IntHasher> map(COUNT);
for (uint64_t i = 0; i < COUNT; i++)
{
uint64_t v = twist_uint64(&tw);
map.insert({v, v});
}
return 0;
}
+3 -3
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html" class="active"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html" class="active"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -269,7 +269,7 @@ int main(void)
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../utl/timer.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../utl/timer.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
@@ -283,7 +283,7 @@ int main(void)
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../utl/timer.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../utl/timer.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
+1 -1
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html" class="active"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html" class="active"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html" class="active"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html" class="active"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -150,6 +150,7 @@
<main>
<h1><a class="header" href="#how-to-use-the-library" id="how-to-use-the-library">How to Use the Library</a></h1>
<p>The C Macro Collections Library comes with very powerful data structures and they are only one macro away from you.</p>
<p>TODO</p>
</main>
@@ -162,7 +163,7 @@
<a rel="next" href="../Features/features.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../Overview/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -180,7 +181,7 @@
<a href="../Features/features.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../Overview/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
+7 -1
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html" class="active"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html" class="active"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -153,10 +153,16 @@
<img src="img/logo.png" alt="C Macro Collections Logo" width="300"/>
</p>
<p align="center">Header only, macro generated, generic and type-safe Collections in C.</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections"><img src="https://img.shields.io/badge/GitHub-C%20Macro%20Collections-2195F3.svg?logo=github" alt="LinkToRepo"/></a>
<a href="https://leoven.github.io/C-Macro-Collections/"><img style="color: #ffffff;" src="https://img.shields.io/badge/Read%20the%20Docs-D13636.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHN0eWxlPSIiPjxyZWN0IGlkPSJiYWNrZ3JvdW5kcmVjdCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgeD0iMCIgeT0iMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJub25lIi8%2BPHRpdGxlPmljbi9kb2MtdGV4dDwvdGl0bGU%2BPGcgY2xhc3M9ImN1cnJlbnRMYXllciIgc3R5bGU9IiI%2BPHRpdGxlPkxheWVyIDE8L3RpdGxlPjxwYXRoIGQ9Ik01IDFoNC4yNDRhMiAyIDAgMCAxIDEuNDM0LjYwNmwyLjc1NiAyLjgzNEEyIDIgMCAwIDEgMTQgNS44MzVWMTJhMyAzIDAgMCAxLTMgM0g1YTMgMyAwIDAgMS0zLTNWNGEzIDMgMCAwIDEgMy0zem0wIDJhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjUuODM1TDkuMjQ0IDNINXptMS41IDdoM2EuNS41IDAgMSAxIDAgMWgtM2EuNS41IDAgMSAxIDAtMXptMC0yaDJhLjUuNSAwIDAgMSAwIDFoLTJhLjUuNSAwIDAgMSAwLTF6TTggMmwzIDEuOTk1TDEzIDdIOWExIDEgMCAwIDEtMS0xVjJ6IiBpZD0iYSIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8%2BPC9nPjwvc3ZnPg%3D%3D" alt="LinkToDocs"/></a>
</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"/></a>
<img src="https://img.shields.io/badge/Version-v0.23.1-orange.svg" alt="Version"/>
<a href="https://travis-ci.org/LeoVen/C-Macro-Collections"><img src="https://travis-ci.org/LeoVen/C-Macro-Collections.svg?branch=master" alt="travis-ci"/></a>
<a href="https://codecov.io/gh/LeoVen/C-Macro-Collections"><img src="https://codecov.io/gh/LeoVen/C-Macro-Collections/branch/master/graph/badge.svg" alt="codecov"/></a>
<img src="https://github.com/LeoVen/C-Macro-Collections/workflows/Test%20Suit/badge.svg?branch=master" alt="test_suit"/>
</p>
<p>The C Macro Collections Library is a compilation of macros that can be used to generate common data structures for any desired type. These data structures are <a href="https://en.wikipedia.org/wiki/Type_safety">type safe</a> and are powered with many features (see Features section).</p>
<p>The documentation is currently being written in hopes that in the future it can be used to help you get to know better this amazing C library.</p>
+1 -1
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html" class="active"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html" class="active"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html" class="active"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html" class="active"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
+2 -2
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html" class="active"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html" class="active"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -164,7 +164,7 @@
<li><strong>Nesting</strong> - Collections can be nested (List of Lists, HashSet of Stacks, etc);</li>
<li><strong>One macro to rule them all</strong> - Only one macro to generate everything and that's it.</li>
</ul>
<p>and many other powerful features (see <a href="../Features/features.html">Features</a>).</p>
<p>and many other powerful features (see <a href="../Overview/features_overview.html">Features</a>).</p>
</main>
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html" class="active"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html" class="active"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -172,13 +172,13 @@
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../Features/functions_table.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../Overview/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../utl/utl.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../Overview/features_overview.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -190,13 +190,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../Features/functions_table.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../Overview/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../utl/utl.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../Overview/features_overview.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Callbacks - C Macro Collections</title>
<title>Features Overview - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html" class="active"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html" class="active"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,29 +148,28 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#callbacks" id="callbacks">Callbacks</a></h1>
<p>Every collection can have an optional callback node. In this node there are five functions:</p>
<table><thead><tr><th></th><th></th></tr></thead><tbody>
<tr><td><code>create</code></td><td>Is called when an element was successfully added to the collection</td></tr>
<tr><td><code>read</code></td><td>Is called when the collection was successfully queried about an element</td></tr>
<tr><td><code>update</code></td><td>Is called when an element in the collection was successfully updated</td></tr>
<tr><td><code>delete</code></td><td>Is called when an element was successfully removed from the collection</td></tr>
<tr><td><code>resize</code></td><td>Is called when the collection was full and successfully resized</td></tr>
<h1><a class="header" href="#features-overview" id="features-overview">Features Overview</a></h1>
<p>The C Macro Collections library comes with some core features available to all collections.</p>
<table><thead><tr><th>Feature</th><th>Description</th></tr></thead><tbody>
<tr><td><a href="../cor/callbacks/index.html">Callbacks</a></td><td>Callbacks are functions that are called when an operation is successful. These operations are divided in 5 categories (create, read, update, delete, resize).</td></tr>
<tr><td><a href="../cor/custom_allocation/index.html">Custom Allocation</a></td><td>Allows you to use your own custom dynamic memory allocation functions inside the collections.</td></tr>
<tr><td><a href="../cor/error_codes/index.html">Error Codes</a></td><td>Error codes that can be used to treat certain common errors when operating on a collection.</td></tr>
<tr><td><a href="../cor/functions_table/index.html">Functions Table</a></td><td>A standard way to access required behaviors from the custom data types. Things like hash, comparison, freeing from memory if needed, etc.</td></tr>
<tr><td><a href="../cor/iterators/index.html">Iterators</a></td><td>Iterators are a simplified access to the values of a collection.</td></tr>
</tbody></table>
<p>Check the documentation for each collection to see which functions call which callbacks.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../Features/custom_allocation.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../Overview/collections_overview.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../Features/functions_table.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../Overview/files_overview.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -182,13 +181,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../Features/custom_allocation.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../Overview/collections_overview.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../Features/functions_table.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../Overview/files_overview.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Custom allocation - C Macro Collections</title>
<title>Files Overview - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html" class="active"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html" class="active"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,13 +148,46 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#custom-allocation" id="custom-allocation">Custom Allocation</a></h1>
<p>All collections have an allocation node. This node can be modified so that every allocation and de-allocation can be done with custom functions. The allocation node has pointers to functions that correspond to:</p>
<h1><a class="header" href="#files-overview" id="files-overview">Files Overview</a></h1>
<p>An overview of the source files (all <code>.h</code>) of the C Macro Collections library.</p>
<ul>
<li><code>calloc</code></li>
<li><code>free</code></li>
<li><code>malloc</code></li>
<li><code>realloc</code></li>
<li><code>./cmc</code> - The main C Macro Collections library
<ul>
<li><code>./bidimap.h</code> - A bi-directional map based on a hash table</li>
<li><code>./deque.h</code> - A double-ended queue</li>
<li><code>./hashmap.h</code> - A map based on a hash table</li>
<li><code>./hashset.h</code> - A set based on a hash table</li>
<li><code>./heap.h</code> - A binary heap based on a dynamic array</li>
<li><code>./intervalheap.h</code> - A heap that is both Min and Max based on a dynamic array</li>
<li><code>./linkedlist.h</code> - A doubly-linked list</li>
<li><code>./list.h</code> - A dynamic array</li>
<li><code>./multimap.h</code> - A map that accepts multiple keys based on a hash table</li>
<li><code>./multiset.h</code> - A multiset based on a hash table</li>
<li><code>./queue.h</code> - A FIFO based on a circular dynamic array</li>
<li><code>./sortedlist.h</code> - A sorted list based on a dynamic array</li>
<li><code>./stack.h</code> - A LIFO based on a dynamic array</li>
<li><code>./treemap.h</code> - A sorted map based on an AVL tree</li>
<li><code>./treeset.h</code> - A sorted set based on an AVL tree</li>
</ul>
</li>
<li><code>./cor</code> - Core functionalities of the C Macro Collections libraries
<ul>
<li><code>./core.h</code> - Core functionalities of the library</li>
<li><code>./hashtable.h</code> - Common things used by hash table based collections</li>
</ul>
</li>
<li><code>./dev</code> - A mirror of the main library to be used during development</li>
<li><code>./sac</code> - Statically Allocated Collections that don't use dynamic allocation</li>
<li><code>./utl</code> - Utilities
<ul>
<li><code>./assert.h</code> - Non-abortive assert macros</li>
<li><code>./foreach.h</code> - For Each macros</li>
<li><code>./futils.h</code> - Common functions used by Functions Table</li>
<li><code>./log.h</code> - Logging utility with levels of severity</li>
<li><code>./test.h</code> - Simple Unit Test building with macros</li>
<li><code>./test.h</code> - Timing code execution utility</li>
</ul>
</li>
</ul>
</main>
@@ -162,13 +195,13 @@
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../Features/two_way_iterators.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../Overview/features_overview.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../Features/callbacks.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../cor/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -180,13 +213,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../Features/two_way_iterators.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../Overview/features_overview.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../Features/callbacks.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../cor/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Features - C Macro Collections</title>
<title>Overview - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html" class="active"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html" class="active"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,8 +148,8 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#features" id="features">Features</a></h1>
<p>The C Macro Collections Library comes with powerful collections. In this section you will better understand many features that are common to all data structures.</p>
<h1><a class="header" href="#overview" id="overview">Overview</a></h1>
<p>In this section you will be able to quickly glance at what are the core functionalities that the C Macro Collections library can bring you.</p>
</main>
@@ -162,7 +162,7 @@
<a rel="next" href="../Features/two_way_iterators.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../Overview/collections_overview.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -180,7 +180,7 @@
<a href="../Features/two_way_iterators.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../Overview/collections_overview.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
+286
View File
@@ -0,0 +1,286 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>bitset.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html" class="active"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#bitseth" id="bitseth">bitset.h</a></h1>
<p>A Bit Set is an array where each bit can be individually modified and queried by using bitwise operators such as <code>|</code>, <code>&amp;</code>, <code>^</code>, <code>~</code>, <code>&gt;&gt;</code> and <code>&lt;&lt;</code> (<code>or</code>, <code>and</code>, <code>xor</code>, <code>not</code>, <code>right shift</code>, <code>left shift</code> respectively).</p>
<h2><a class="header" href="#bitset-implementation" id="bitset-implementation">BitSet Implementation</a></h2>
<p>This BitSet implementation uses an array of type <code>cmc_bitset_word</code> which can be <code>typedef</code>ed to any unsigned type such as <code>uint8_t</code>, <code>uint16_t</code>, <code>uint32_t</code>, <code>uint64_t</code>, <code>size_t</code>, etc. The BitSet does not make use of <code>K</code> or <code>V</code>. Because of that, it also doesn't have Functions Tables.</p>
<p>The BitSet is initialized with a custom capacity but, if a bit index accessed is greater than the total capacity, the BitSet will resize. This means that the BitSet will try to guarantee that every bit index is accessible, as long as there is enough memory.</p>
<h2><a class="header" href="#bitset-generation-macros" id="bitset-generation-macros">BitSet Generation Macros</a></h2>
<ul>
<li><code>CMC_GENERATE_BITSET(PFX, SNAME)</code> - Generate full definition.</li>
<li><code>CMC_GENERATE_BITSET_HEADER(PFX, SNAME)</code> - Generate only the header portion</li>
<li><code>CMC_GENERATE_BITSET_SOURCE(PFX, SNAME)</code> - Generate only the source portion</li>
</ul>
<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody>
<tr><td><code>PFX</code></td><td>Functions namespace or prefix</td></tr>
<tr><td><code>SNAME</code></td><td>Structure name</td></tr>
</tbody></table>
<h2><a class="header" href="#bitset-structures" id="bitset-structures">BitSet Structures</a></h2>
<table><thead><tr><th>Declared structs</th><th>Description</th></tr></thead><tbody>
<tr><td><code>struct SNAME</code></td><td>A bit set data structure</td></tr>
<tr><td><code>struct SNAME##_iter</code></td><td>A bit set iterator</td></tr>
</tbody></table>
<h2><a class="header" href="#struct-sname" id="struct-sname">struct SNAME</a></h2>
<table><thead><tr><th><code>struct SNAME</code></th><th>Description</th></tr></thead><tbody>
<tr><td><code>cmc_bitset_word *buffer</code></td><td>Dynamic array of bits.</td></tr>
<tr><td><code>size_t capacity</code></td><td>Current array capacity .</td></tr>
<tr><td><code>int flag</code></td><td>Flag indicating errors or success.</td></tr>
<tr><td><code>struct cmc_alloc_node *alloc</code></td><td>Custom allocation functions.</td></tr>
<tr><td><code>struct cmc_callbacks *callbacks</code></td><td>Callback functions.</td></tr>
</tbody></table>
<h2><a class="header" href="#struct-sname_iter" id="struct-sname_iter">struct SNAME##_iter</a></h2>
<table><thead><tr><th><code>struct SNAME##_iter</code></th><th>Description</th></tr></thead><tbody>
<tr><td><code>struct SNAME *target</code></td><td>BitSet being iterated over.</td></tr>
<tr><td><code>size_t cursor</code></td><td>Cursor's current position (index).</td></tr>
<tr><td><code>bool start</code></td><td>If the iterator reached the start of the iteration.</td></tr>
<tr><td><code>bool end</code></td><td>If the iterator reached the end of iteration.</td></tr>
</tbody></table>
<h2><a class="header" href="#cmc_bitset_word" id="cmc_bitset_word">cmc_bitset_word</a></h2>
<p>The <code>typedef</code>ed data type o the underlying bit set buffer.</p>
<pre><code class="language-c">typedef uint32_t cmc_bitset_word;
</code></pre>
<p>This <code>typedef</code> can be changed to any unsigned integer data type and the bit set will still work properly.</p>
<h2><a class="header" href="#callbacks" id="callbacks">Callbacks</a></h2>
<p>This list associates which functions calls which callbacks.</p>
<ul>
<li><code>create</code>
<ul>
<li><code>PFX##_set()</code></li>
<li><code>PFX##_set_range()</code></li>
</ul>
</li>
<li><code>read</code></li>
<li><code>update</code></li>
<li><code>delete</code>
<ul>
<li><code>PFX##_clear()</code></li>
<li><code>PFX##_clear_range()</code></li>
</ul>
</li>
<li><code>resize</code>
<ul>
<li><code>PFX##_resize()</code></li>
</ul>
</li>
</ul>
<h2><a class="header" href="#functions-table" id="functions-table">Functions Table</a></h2>
<table><thead><tr><th align="center">CMP</th><th align="center">CPY</th><th align="center">STR</th><th align="center">FREE</th><th align="center">HASH</th><th align="center">PRI</th></tr></thead><tbody>
<tr><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td></tr>
</tbody></table>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../cmc/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../cmc/deque.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../cmc/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../cmc/deque.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+277
View File
@@ -0,0 +1,277 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Functions.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html" class="active"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#index" id="index">Index</a></h1>
<p><strong>Deque</strong></p>
<ul>
<li><a href="#_new"><code>_new()</code></a></li>
<li><a href="#_new_custom"><code>_new_custom()</code></a></li>
<li><code>_clear()</code></li>
<li><code>_free()</code></li>
<li><code>_customize()</code></li>
<li><code>_push_front()</code></li>
<li><code>_push_back()</code></li>
<li><code>_pop_front()</code></li>
<li><code>_front()</code></li>
<li><code>_back()</code></li>
<li><code>_contains()</code></li>
<li><code>_empty()</code></li>
<li><code>_full()</code></li>
<li><code>_count()</code></li>
<li><code>_capacity()</code></li>
<li><code>_flag()</code></li>
<li><code>_resize()</code></li>
<li><code>_copy_of()</code></li>
<li><code>_equals()</code></li>
<li><code>_to_string()</code></li>
<li><code>_print()</code></li>
</ul>
<p><strong>Deque Iterator</strong></p>
<p>WIP.</p>
<h2><a class="header" href="#a-hrefindexspan-id_new-_new-spana" id="a-hrefindexspan-id_new-_new-spana"><a href="#index"><span id="_new"> _new() </span></a></a></h2>
<p>Allocates on the heap and returns a new Deque with an internal capacity of the specified value. The Deque will be empty, using the default allocator <code>cmc_alloc_node_default</code> and no callbacks will be set, that is, <code>callbacks</code> will be set to <code>NULL</code>. Its <code>flag</code> will be initially <code>cmc_flags.OK</code>.</p>
<p><strong>Declaration</strong></p>
<p><code>struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val);</code></p>
<p><strong>Parameters</strong></p>
<table><thead><tr><th>Parameter</th><th>Required</th><th>Description</th></tr></thead><tbody>
<tr><td><code>size_t capacity</code></td><td>Yes</td><td>The initial Deque capacity</td></tr>
<tr><td><code>struct SNAME##_fval *f_val</code></td><td>Yes</td><td>A Functions Table for <code>V</code></td></tr>
</tbody></table>
<p><strong>Returns</strong></p>
<table><thead><tr><th>Returns</th><th>When</th></tr></thead><tbody>
<tr><td><code>struct SNAME *</code></td><td>If operation was successful</td></tr>
<tr><td><code>NULL</code></td><td>If allocation failed, if capacity is <code>0</code> or if <code>f_val</code> is <code>NULL</code></td></tr>
</tbody></table>
<h2><a class="header" href="#a-hrefindexspan-id_new_custom-_new_custom-spana" id="a-hrefindexspan-id_new_custom-_new_custom-spana"><a href="#index"><span id="_new_custom"> _new_custom() </span></a></a></h2>
<p>Like <a href="#_new">_new()</a> but allows for custom allocation node and callbacks. The allocation node is optional. If present, the function will immediately use it to allocate the new Deque. If <code>NULL</code>, <code>cmc_alloc_node_default</code> will instead be used.</p>
<p><strong>Declaration</strong></p>
<pre><code>struct SNAME *PFX##_new_custom(size_t capacity, struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
</code></pre>
<p><strong>Parameters</strong></p>
<table><thead><tr><th>Parameter</th><th>Required</th><th>Description</th></tr></thead><tbody>
<tr><td><code>size_t capacity</code></td><td>Yes</td><td>The initial Deque capacity</td></tr>
<tr><td><code>struct SNAME##_fval *f_val</code></td><td>Yes</td><td>A Functions Table for <code>V</code></td></tr>
<tr><td><code>struct cmc_alloc_node *alloc</code></td><td>No</td><td>A custom allocation node</td></tr>
<tr><td><code>struct cmc_callbacks *callbacks</code></td><td>No</td><td>A custom callbacks struct</td></tr>
</tbody></table>
<p><strong>Returns</strong></p>
<table><thead><tr><th>Returns</th><th>When</th></tr></thead><tbody>
<tr><td><code>struct SNAME *</code></td><td>If operation was successful</td></tr>
<tr><td><code>NULL</code></td><td>If allocation failed, if capacity is <code>0</code> or if <code>f_val</code> is <code>NULL</code></td></tr>
</tbody></table>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../cmc/deque.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../dev/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../cmc/deque.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../dev/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+296
View File
@@ -0,0 +1,296 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>deque.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html" class="active"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#dequeh" id="dequeh">deque.h</a></h1>
<p>A Deque, also known as a double-ended queue, is a linear data structure that is able to add and remove elements from both ends. It can also be thought of a double-ended stack since you can push and pop elements from two ends. The Deque can also be used as a Queue. The only elements accessible from a Deque ar the two elements at its ends (front element and back element).</p>
<h2><a class="header" href="#deque-implementation" id="deque-implementation">Deque Implementation</a></h2>
<p>This implementation uses a circular buffer (ring buffer or cyclic buffer) in order to operate on O(1) for push and pop on either ends. The only case where it takes longer than O(1) is when the buffer is reallocated. If it was implemented as a regular array, adding or removing elements from the front would take O(N) due to the need to shift all elements in the Deque.</p>
<p>Two indices are kept track of. The <code>front</code> index and the <code>rear</code> index. These represent the both ends of the Deque. If an index reaches one end of the real buffer, they wrap around to the other end and an element is added there. This abstracts the real buffer as a circular buffer with the cost os constantly checking for boundaries and using the modulo operator.</p>
<h2><a class="header" href="#deque-generation-macros" id="deque-generation-macros">Deque Generation Macros</a></h2>
<ul>
<li><code>CMC_GENERATE_DEQUE(PFX, SNAME, V)</code> - Generate full definition.</li>
<li><code>CMC_GENERATE_DEQUE_HEADER(PFX, SNAME, V)</code> - Generate only the header portion</li>
<li><code>CMC_GENERATE_DEQUE_SOURCE(PFX, SNAME, V)</code> - Generate only the source portion</li>
</ul>
<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody>
<tr><td><code>PFX</code></td><td>Functions namespace or prefix</td></tr>
<tr><td><code>SNAME</code></td><td>Structure name</td></tr>
<tr><td><code>V</code></td><td>Value type</td></tr>
</tbody></table>
<h2><a class="header" href="#deque-structures" id="deque-structures">Deque Structures</a></h2>
<table><thead><tr><th>Declared structs</th><th>Description</th></tr></thead><tbody>
<tr><td><code>struct SNAME</code></td><td>A double-ended queue data structure</td></tr>
<tr><td><code>struct SNAME##_fval</code></td><td>A function table for the <code>V</code> type</td></tr>
<tr><td><code>struct SNAME##_iter</code></td><td>A double-ended queue iterator</td></tr>
</tbody></table>
<h2><a class="header" href="#struct-sname" id="struct-sname">struct SNAME</a></h2>
<table><thead><tr><th><code>struct SNAME</code></th><th>Description</th></tr></thead><tbody>
<tr><td><code>V *buffer</code></td><td>Dynamic circular array of elements.</td></tr>
<tr><td><code>size_t capacity</code></td><td>Current circular array capacity.</td></tr>
<tr><td><code>size_t count</code></td><td>Current amount of elements.</td></tr>
<tr><td><code>size_t front</code></td><td>Index representing the front of the Deque.</td></tr>
<tr><td><code>size_t rear</code></td><td>Index representing the back of the Deque.</td></tr>
<tr><td><code>int flag</code></td><td>Flag indicating errors or success.</td></tr>
<tr><td><code>struct SNAME##_fval *f_val</code></td><td>Functions table for the Value type.</td></tr>
<tr><td><code>struct cmc_alloc_node *alloc</code></td><td>Custom allocation functions.</td></tr>
<tr><td><code>struct cmc_callbacks *callbacks</code></td><td>Callback functions.</td></tr>
</tbody></table>
<h2><a class="header" href="#struct-sname_fval" id="struct-sname_fval">struct SNAME##_fval</a></h2>
<p>The Functions Table for <code>V</code>. Check out the Functions Table documentation <a href="../../cor/functions_table/index.html">here</a>.</p>
<h2><a class="header" href="#struct-sname_iter" id="struct-sname_iter">struct SNAME##_iter</a></h2>
<table><thead><tr><th><code>struct SNAME##_iter</code></th><th>Description</th></tr></thead><tbody>
<tr><td><code>struct SNAME *target</code></td><td>Deque being iterated over.</td></tr>
<tr><td><code>size_t cursor</code></td><td>Cursor's current position (index).</td></tr>
<tr><td><code>size_t index</code></td><td>Relative index to all elements in the iteration.</td></tr>
<tr><td><code>bool start</code></td><td>If the iterator reached the start of the iteration.</td></tr>
<tr><td><code>bool end</code></td><td>If the iterator reached the end of iteration.</td></tr>
</tbody></table>
<h2><a class="header" href="#callbacks" id="callbacks">Callbacks</a></h2>
<p>This list associates which functions calls which callbacks.</p>
<ul>
<li><code>create</code>
<ul>
<li><code>PFX##_push_front()</code></li>
<li><code>PFX##_push_back()</code></li>
</ul>
</li>
<li><code>read</code>
<ul>
<li><code>PFX##_front()</code></li>
<li><code>PFX##_back()</code></li>
<li><code>PFX##_contains()</code></li>
</ul>
</li>
<li><code>update</code></li>
<li><code>delete</code>
<ul>
<li><code>PFX##_pop_front()</code></li>
<li><code>PFX##_pop_back()</code></li>
</ul>
</li>
<li><code>resize</code>
<ul>
<li><code>PFX##_resize()</code></li>
</ul>
</li>
</ul>
<h2><a class="header" href="#functions-table" id="functions-table">Functions Table</a></h2>
<table><thead><tr><th align="center">CMP</th><th align="center">CPY</th><th align="center">STR</th><th align="center">FREE</th><th align="center">HASH</th><th align="center">PRI</th></tr></thead><tbody>
<tr><td align="center"><img src="https://placehold.it/20/9f3b94/000000?text=+" alt="#9f3b94" /></td><td align="center"><img src="https://placehold.it/20/9f3b94/000000?text=+" alt="#9f3b94" /></td><td align="center"><img src="https://placehold.it/20/497edd/000000?text=+" alt="#497edd" /></td><td align="center"><img src="https://placehold.it/20/00d3eb/000000?text=+" alt="#00d3eb" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td></tr>
</tbody></table>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../cmc/bitset.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../cmc/deque.h/functions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../cmc/bitset.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../cmc/deque.h/functions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+238
View File
@@ -0,0 +1,238 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>cmc - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html" class="active"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#cmc" id="cmc">CMC</a></h1>
<p>The main C Macro Collections.</p>
<p>The C Macro Collections library was created out of necessity. To create powerful data structures of any type without the constant use of macros and <code>void *</code> pointers, but at the same time being <a href="https://en.wikipedia.org/wiki/Type_safety">type-safe</a>. These collections are generated by macros containing a template. These templates allow for some much needed customizations including the data type you wish to handle.</p>
<p>In the <code>cmc</code> folder is the default implementation of all collections. There is also a <code>dev</code> folder that pretty much has the same macros that expand to the same code, except that they have an extensive use of logging that might be useful for debugging or getting to know what is happening in your program. There is also the <code>sac</code> collections that are statically allocated (have a fixed sized buffer).</p>
<h2><a class="header" href="#quick-example" id="quick-example">Quick Example</a></h2>
<p>Let's say you need a HashMap mapping keys of type <code>char *</code> to <code>int</code>. All you need to do is:</p>
<pre><code class="language-c">#include &quot;cmc/hashmap&quot;
// CMC_GENERATE_HASHMAP(PFX, SNAME, K, V)
CMC_GENERATE_HASHMAP(map, hashmap, char *, int)
int main(void)
{
// Here you have full functionalities of a HashMap
// No more macros needed!
// Every function can be found in the 'map_' prefix and are all type-safe
}
</code></pre>
<p>You can customize the functions prefix (<code>PFX</code>) and the <code>struct</code> name (<code>SNAME</code>). The macro <code>CMC_GENERATE_HASHMAP</code> will expand to all the code that you will need to operate on a HashMap with <code>char *</code> keys and <code>int</code> values. The only thing left to do is to define a hash function and a comparator functions for the keys of this map. In case of <code>char *</code> you can find these functions in <code>utl/futils.h</code> or make your own. To know which collections require which functions check out <a href="../cor/functions_table/index.html">Functions Table</a> or the documentation for each collection.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../cor/iterators/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../cmc/bitset.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../cor/iterators/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../cmc/bitset.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+269
View File
@@ -0,0 +1,269 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Callbacks - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html" class="active"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#callbacks" id="callbacks">Callbacks</a></h1>
<p>Every collection can have an optional callback node. In this node there are five functions:</p>
<table><thead><tr><th>Callback</th><th>Description</th></tr></thead><tbody>
<tr><td><code>create</code></td><td>Is called when an element was successfully added to the collection</td></tr>
<tr><td><code>read</code></td><td>Is called when the collection was successfully queried about an element</td></tr>
<tr><td><code>update</code></td><td>Is called when an element in the collection was successfully updated</td></tr>
<tr><td><code>delete</code></td><td>Is called when an element was successfully removed from the collection</td></tr>
<tr><td><code>resize</code></td><td>Is called when the collection was full and successfully resized</td></tr>
</tbody></table>
<p>Check the documentation for each collection to see which functions call which callbacks.</p>
<h2><a class="header" href="#cmc_callbacks" id="cmc_callbacks">cmc_callbacks</a></h2>
<p>Every collection has a pointer to this <code>struct</code>. If it is <code>NULL</code> then the collection has no callbacks. Also, individual callbacks can be optional if set to <code>NULL</code>.</p>
<pre><code class="language-c">struct cmc_callbacks
{
void (*create)(void);
void (*read)(void);
void (*update)(void);
void (*delete)(void);
void (*resize)(void);
};
</code></pre>
<h2><a class="header" href="#example" id="example">Example</a></h2>
<pre><code class="language-c">#include &quot;cmc/heap.h&quot;
#include &quot;utl/futils.h&quot; // cmc_i32_cmp
// Generate a heap of integers
CMC_GENERATE_HEAP(i32h, i32heap, int)
void heap_on_create(void)
{
printf(&quot;An element was added to the heap\n&quot;);
}
int main(void)
{
// create() is set but the other callbacks are not
struct cmc_callbacks my_callbacks = { .create = heap_on_create, NULL };
// Create a max heap with the callbacks
struct i32heap *heap = i32h_new_custom(
100, cmc_max_heap, &amp;(struct i32heap_fval){ .cmp = cmc_i32_cmp }, NULL,
&amp;my_callbacks);
i32h_insert(heap, 10);
i32h_insert(heap, 11);
i32h_insert(heap, 12);
i32h_free(heap);
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../cor/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../cor/custom_allocation/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../cor/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../cor/custom_allocation/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+299
View File
@@ -0,0 +1,299 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Custom allocation - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html" class="active"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#custom-allocation" id="custom-allocation">Custom Allocation</a></h1>
<p>All collections have an allocation node. This node can be modified so that every allocation and de-allocation can be done with custom functions. Every custom allocation function must follow the same prototype of the <code>stdlib.h</code> functions.</p>
<h2><a class="header" href="#cmc_alloc_node" id="cmc_alloc_node">cmc_alloc_node</a></h2>
<pre><code class="language-c">struct cmc_alloc_node
{
void *(*malloc)(size_t);
void *(*calloc)(size_t, size_t);
void *(*realloc)(void *, size_t);
void (*free)(void *);
};
</code></pre>
<h2><a class="header" href="#cmc_alloc_node_default" id="cmc_alloc_node_default">cmc_alloc_node_default</a></h2>
<p>The default allocation node. If a collections is not initialized with a custom allocation node, this will be the default one using the functions from the C standard library.</p>
<pre><code class="language-c">static struct cmc_alloc_node cmc_alloc_node_default = { malloc, calloc,
realloc, free };
</code></pre>
<h2><a class="header" href="#example" id="example">Example</a></h2>
<pre><code class="language-c">#include &quot;cmc/heap.h&quot;
#include &quot;utl/futils.h&quot; // cmc_i32_cmp
// Total bytes allocated
size_t total = 0;
void *my_malloc(size_t size)
{
void *result = malloc(size);
if (!result)
return result;
total += size;
return result;
}
void *my_calloc(size_t count, size_t size)
{
void *result = calloc(count, size);
if (!result)
return result;
total += count * size;
return result;
}
void *my_realloc(void *block, size_t size)
{
void *result = realloc(block, size);
if (!result)
return result;
total += size;
return result;
}
// Generate a heap of integers
CMC_GENERATE_HEAP(i32h, i32heap, int)
int main(void)
{
// My custom allocation node
struct cmc_alloc_node node = { .malloc = my_malloc,
.calloc = my_calloc,
.realloc = my_realloc,
.free = free };
// Create a max heap with the custom allocation node
struct i32heap *heap = i32h_new_custom(
100, cmc_max_heap, &amp;(struct i32heap_fval){ .cmp = cmc_i32_cmp }, &amp;node,
NULL);
for (int i = 0; i &lt; 100000; i++)
i32h_insert(heap, i);
i32h_free(heap);
printf(&quot;Total bytes allocated : %&quot; PRIuMAX &quot;\n&quot;, total);
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../cor/callbacks/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../cor/error_codes/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../cor/callbacks/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../cor/error_codes/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+281
View File
@@ -0,0 +1,281 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Error Codes - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html" class="active"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#error-codes" id="error-codes">Error Codes</a></h1>
<p>Error codes are ways to signal errors or success. It is accessed through the <code>flag</code> component of a <code>struct</code> or through a function that is present in every collection:</p>
<pre><code class="language-c">int PFX##_flag(struct SNAME *_collection_);
</code></pre>
<p>Some functions have a return type of <code>bool</code> indicating if it exited successfully or not. These error codes can be used for further error handling.</p>
<h2><a class="header" href="#cmc_flags" id="cmc_flags">cmc_flags</a></h2>
<p>It is a global <code>struct</code> with default values for error codes.</p>
<pre><code class="language-c">static struct
{
int OK;
int ALLOC;
int EMPTY;
int NOT_FOUND;
int INVALID;
int RANGE;
int DUPLICATE;
int ERROR;
} cmc_flags = { 0, 1, 2, 3, 4, 5, 6, 7 };
</code></pre>
<ul>
<li><code>OK</code> - No errors. The operation exited successfully.</li>
<li><code>ALLOC</code> - Allocation failed.</li>
<li><code>EMPTY</code> - The collection is empty when it shouldn't.</li>
<li><code>NOT_FOUND</code> - Key or value not found.</li>
<li><code>INVALID</code> - Invalid argument or operation given the collection's state</li>
<li><code>RANGE</code> - Index out of range.</li>
<li><code>DUPLICATE</code> - Duplicate key or value.</li>
<li><code>ERROR</code> - Generic error. Usually caused by algorithm errors.</li>
</ul>
<h2><a class="header" href="#cmc_flags_to_str" id="cmc_flags_to_str">cmc_flags_to_str</a></h2>
<p>Maps the integer representation of error codes to their character representation.</p>
<pre><code class="language-c">const char *cmc_flags_to_str[8] = { &quot;OK&quot;, &quot;ALLOC&quot;, &quot;EMPTY&quot;,
&quot;NOT_FOUND&quot;, &quot;INVALID&quot;, &quot;RANGE&quot;,
&quot;DUPLICATE&quot;, &quot;ERROR&quot; };
</code></pre>
<h2><a class="header" href="#example" id="example">Example</a></h2>
<pre><code class="language-c">#include &quot;cmc/treeset.h&quot;
#include &quot;utl/futils.h&quot; // cmc_i32_cmp
// Generate a sorted set of integers
CMC_GENERATE_TREESET(tset, sortedset, int)
int main(void)
{
struct sortedset *set =
tset_new(&amp;(struct sortedset_fval){ .cmp = cmc_i32_cmp });
if (!tset_insert(set, 10))
printf(&quot;Error! %s\n&quot;, cmc_flags_to_str[tset_flag(set)]);
if (!tset_insert(set, 10))
printf(&quot;Error! %s\n&quot;, cmc_flags_to_str[tset_flag(set)]);
if (!tset_remove(set, 10))
printf(&quot;Error! %s\n&quot;, cmc_flags_to_str[tset_flag(set)]);
if (!tset_remove(set, 10))
printf(&quot;Error! %s\n&quot;, cmc_flags_to_str[tset_flag(set)]);
tset_free(set);
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../cor/custom_allocation/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../cor/functions_table/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../cor/custom_allocation/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../cor/functions_table/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
@@ -11,21 +11,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
@@ -35,7 +35,7 @@
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../";
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html" class="active"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html" class="active"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -116,7 +116,7 @@
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
@@ -149,29 +149,88 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#functions-table" id="functions-table">Functions Table</a></h1>
<p>Functions table are like a methods table for you custom data type. It is a <code>struct</code> of function pointers that you will need to define in order to some collections to work. Some functions are optional and others are needed in order to a collection to operate.</p>
<p>Functions Table is a <code>struct</code> with function pointers that are used to extract behavior from a custom data type. This exists because an <code>int</code> or a <code>char *</code> or <code>struct my_data_type</code> don't have default hash functions or ways to compare between them. This could be achieved with <a href="https://en.wikipedia.org/wiki/Operator_overloading">operator overloading</a> but C doesn't have that. Hence, Functions Table was created to provide a single access point to extract these behaviors for <strong>any</strong> data type.</p>
<p>Some functions are optional and others are needed in order for a collection to operate. Say you want a HashMap. There are two required functions: <code>hash</code> and <code>cmp</code> (comparator). Without them it is impossible to know how to hash your custom that type (it could be anything). This means you can also customize the collection by using different hash functions.</p>
<p>Many required functions are simply mundane. Like a comparator function between integers or between floats. The header <a href="../../utl/futils.h/index.html"><code>utl/futils.h</code></a> defines many of these functions for basic C data types.</p>
<p>Some collections generate two functions table. One for <code>K</code> and one for <code>V</code> (maps). Others simply generate one for <code>V</code>. A Functions Table <code>struct</code> is always going to be called:</p>
<ul>
<li><code>struct SNAME##_fkey</code> for the <code>K</code> type</li>
<li><code>struct SNAME##_fval</code> for the <code>V</code> type</li>
</ul>
<p>Their definition is defined as follows:</p>
<pre><code class="language-c"> \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
\
/* Copy function */ \
K (*cpy)(K); \
\
/* To string function */ \
bool (*str)(FILE *, K); \
\
/* Free from memory function */ \
void (*free)(K); \
\
/* Hash function */ \
size_t (*hash)(K); \
\
/* Priority function */ \
int (*pri)(K, K); \
}; \
\
</code></pre>
<h3><a class="header" href="#cmp" id="cmp">CMP</a></h3>
<ul>
<li><code>K</code> - <code>int (*cmp)(K, K)</code></li>
<li><code>V</code> - <code>int (*cmp)(V, V)</code></li>
</ul>
<p>A comparator function is used in sorted collections or when an equality is being checked like when trying to find a certain element in a list. It is responsible for taking two arguments of the same data type and comparing them. The return value is an <code>int</code> with the following definitions:</p>
<ul>
<li>Return <code>1</code> if the first argument is greater than the second;</li>
<li>Return <code>0</code> if the first argument equals the second;</li>
<li>Return <code>-1</code> if the first argument is less than the second.</li>
</ul>
<p>Note that certain collections require a total ordering of its elements (sorted collections) while others only require to know if one data equals another. Check out the documentation for each collection to know more.</p>
<h3><a class="header" href="#cpy" id="cpy">CPY</a></h3>
<ul>
<li><code>K</code> - <code>K (*cpy)(K)</code></li>
<li><code>V</code> - <code>V (*cpy)(V)</code></li>
</ul>
<p>A copy function is used when a collection is being copied. It can be used to make a deep copy of of your custom data type. It must take a single parameter and return a new copy of that same data type. If this function is absent (<code>NULL</code>) the data type will be copied by assignment (for pointers this is a shallow copy).</p>
<p>Note that it doesn't makes sense to define a <code>cpy</code> function for data types that are not pointers. This function is useful for deep copies of a pointer in case you don't want two collections holding the same reference to the data.</p>
<h3><a class="header" href="#str" id="str">STR</a></h3>
<p>A string function is responsible for taking a <code>FILE</code> pointer and a custom data type and outputting the string representation of that data returning a <code>bool</code> indication success or failure. It is useful for debugging.</p>
<ul>
<li><code>K</code> - <code>bool (*str)(FILE *, K)</code></li>
<li><code>V</code> - <code>bool (*str)(FILE *, V)</code></li>
</ul>
<p>A string function is responsible for taking a <code>FILE</code> pointer and a custom data type and outputting the string representation of that data returning a <code>bool</code> indication success or failure. It is useful for debugging and doesn't necessarily needs to print all the data that the specific type holds.</p>
<h3><a class="header" href="#free" id="free">FREE</a></h3>
<p>The free function is called when a collection is cleared (all elements removed) or freed (all elements removed and freed from memory) and it is responsible for completely freeing all resources that are usually acquired by your data type.</p>
<ul>
<li><code>K</code> - <code>void (*free)(K)</code></li>
<li><code>V</code> - <code>void (*free)(V)</code></li>
</ul>
<p>The free function is called when a collection is cleared (all elements removed) or freed (all elements removed and the collection is freed from memory) and it is responsible for completely freeing all resources that are usually acquired by your data type.</p>
<p>This function only makes sense to be used when the data type has dynamically allocated memory. It is the only completely optional function.</p>
<h3><a class="header" href="#hash" id="hash">HASH</a></h3>
<p>This function receives a custom data type as parameter and returns a <code>size_t</code> hash of that data. Used in hashtables.</p>
<ul>
<li><code>K</code> - <code>size_t (*hash)(K)</code></li>
<li><code>V</code> - <code>size_t (*hash)(V)</code></li>
</ul>
<p>This function receives a custom data type as parameter and returns a <code>size_t</code> <a href="https://en.wikipedia.org/wiki/Hash_function">hash</a> that represents that data. Used by collections with an underlying hash tables.</p>
<h3><a class="header" href="#pri" id="pri">PRI</a></h3>
<p>A priority function works much like the comparator function except that it compares the priority between two elements. It is used in collections whose structure is based on the priority of elements and not in their general comparison.</p>
<ul>
<li><code>K</code> - <code>int (*cmp)(K, K)</code></li>
<li><code>V</code> - <code>int (*cmp)(V, V)</code></li>
</ul>
<p>A priority function works much like the comparator function except that it compares the priority between two elements. It is used in collections whose structure is based on the priority of elements and not in their general comparison (heaps).</p>
<ul>
<li>Return <code>1</code> if the first argument has a greater priority than the second;</li>
<li>Return <code>0</code> if the first argument has the same priority as second;</li>
<li>Return <code>-1</code> if the first argument has a lower priority than the second.</li>
</ul>
<p>Why use both <code>cmp</code> and <code>pri</code>? Heaps have their internal structure based in the priority of elements. This priority is not necessarily how each element is compared to each other. Maybe their equality is defined differently for an equality of priorities. Maybe the rules for their priorities is different for when comparing an element against another.</p>
<p>The following table shows which functions are required, optional or never used for each Collection:</p>
<table><thead><tr><th>Collection</th><th align="center">CMP</th><th align="center">CPY</th><th align="center">STR</th><th align="center">FREE</th><th align="center">HASH</th><th align="center">PRI</th></tr></thead><tbody>
<tr><td>BidiMap</td><td align="center"><img src="https://placehold.it/20/b82b28/000000?text=+" alt="#b82b28" /></td><td align="center"><img src="https://placehold.it/20/9f3b94/000000?text=+" alt="#9f3b94" /></td><td align="center"><img src="https://placehold.it/20/497edd/000000?text=+" alt="#497edd" /></td><td align="center"><img src="https://placehold.it/20/00d3eb/000000?text=+" alt="#00d3eb" /></td><td align="center"><img src="https://placehold.it/20/b82b28/000000?text=+" alt="#b82b28" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td></tr>
@@ -204,13 +263,13 @@
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../Features/callbacks.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../../cor/error_codes/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../Overview/overview.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../../cor/iterators/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -222,13 +281,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../Features/callbacks.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../../cor/error_codes/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../Overview/overview.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../../cor/iterators/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -251,14 +310,14 @@
<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../book.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Two way iterators - C Macro Collections</title>
<title>cor - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html" class="active"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html" class="active"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,22 +148,21 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#two-way-iterators" id="two-way-iterators">Two-Way Iterators</a></h1>
<p>Every collection comes with an interface of iterators where you can easily access the elements of a collection. These can move at any direction, can start at any 'end' of a collection and can move any amount of steps per iteration. Every collection generated comes with an iterator.</p>
<p>By design choice these iterators do not support modifications to the collection. If a collection is modified, all iterators that have been initialized will most likely be invalidated and may cause undefined behavior if used afterwards.</p>
<h1><a class="header" href="#cor" id="cor">COR</a></h1>
<p>Core functionalities of the C Macro Collections Library.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../Features/features.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../Overview/files_overview.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../Features/custom_allocation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../cor/callbacks/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -175,13 +174,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../Features/features.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../Overview/files_overview.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../Features/custom_allocation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../cor/callbacks/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Single Value Assertion - C Macro Collections</title>
<title>Iterators - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/single_value_assertion.html" class="active"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html" class="active"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,35 +148,22 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#single-value-assertion-macros" id="single-value-assertion-macros">Single Value Assertion Macros</a></h1>
<h2><a class="header" href="#cmc_assert_state" id="cmc_assert_state">cmc_assert_state</a></h2>
<p>This is a global variable that can be used to test if all assertions passed. If a single assertion fails, this variable will be set to <code>false</code>. If an assertion passes this variable will not be set back to <code>true</code>.</p>
<pre><code class="language-c">static bool cmc_assert_state = true;
</code></pre>
<p>This variable is used in <a href="./test.html">test.h</a> utility to automatically pass or fail a unit test. Once the unit test finishes, this variable is set back to <code>true</code> so that another unit test may follow.</p>
<h2><a class="header" href="#cmc_assert" id="cmc_assert">cmc_assert</a></h2>
<p>Asserts that an expression evaluates to <code>true</code>.</p>
<pre><code class="language-c">#define cmc_assert(expression)
</code></pre>
<h3><a class="header" href="#parameters" id="parameters">Parameters</a></h3>
<ul>
<li><code>expression</code> - An expression that needs to be evaluated to true.</li>
</ul>
<h2><a class="header" href="#cmc_assert_equals" id="cmc_assert_equals">cmc_assert_equals</a></h2>
<p>Asserts that a</p>
<h1><a class="header" href="#iterators" id="iterators">Iterators</a></h1>
<p>Every collection comes with an interface of iterators where you can easily access the elements of a collection. These can move at any direction, can start at any 'end' of a collection and can move any amount of steps per iteration. Every collection generated comes with an iterator.</p>
<p>By design choice these iterators do not support modifications to the collection. If a collection is modified, all iterators that have been initialized will most likely be invalidated and may cause undefined behavior if used afterwards.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/assert.h/overview.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../../cor/functions_table/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/assert.h/array_assertion.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../../cmc/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -188,13 +175,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/assert.h/overview.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../../cor/functions_table/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/assert.h/array_assertion.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../../cmc/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
+8 -8
View File
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>test.h - C Macro Collections</title>
<title>dev - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html" class="active"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html" class="active"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,21 +148,21 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#testh" id="testh">test.h</a></h1>
<p>Simple unit test utility.</p>
<h1><a class="header" href="#dev" id="dev">DEV</a></h1>
<p>The development collections. These collections are an exact copy of the <code>cmc</code> collections but they come with many logging throughout the generated code. Useful for debugging or during development.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../utl/log.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../cmc/deque.h/functions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../utl/timer.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../sac/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -174,13 +174,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../utl/log.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../cmc/deque.h/functions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../utl/timer.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../sac/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
+7 -1
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -153,10 +153,16 @@
<img src="img/logo.png" alt="C Macro Collections Logo" width="300"/>
</p>
<p align="center">Header only, macro generated, generic and type-safe Collections in C.</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections"><img src="https://img.shields.io/badge/GitHub-C%20Macro%20Collections-2195F3.svg?logo=github" alt="LinkToRepo"/></a>
<a href="https://leoven.github.io/C-Macro-Collections/"><img style="color: #ffffff;" src="https://img.shields.io/badge/Read%20the%20Docs-D13636.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHN0eWxlPSIiPjxyZWN0IGlkPSJiYWNrZ3JvdW5kcmVjdCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgeD0iMCIgeT0iMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJub25lIi8%2BPHRpdGxlPmljbi9kb2MtdGV4dDwvdGl0bGU%2BPGcgY2xhc3M9ImN1cnJlbnRMYXllciIgc3R5bGU9IiI%2BPHRpdGxlPkxheWVyIDE8L3RpdGxlPjxwYXRoIGQ9Ik01IDFoNC4yNDRhMiAyIDAgMCAxIDEuNDM0LjYwNmwyLjc1NiAyLjgzNEEyIDIgMCAwIDEgMTQgNS44MzVWMTJhMyAzIDAgMCAxLTMgM0g1YTMgMyAwIDAgMS0zLTNWNGEzIDMgMCAwIDEgMy0zem0wIDJhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjUuODM1TDkuMjQ0IDNINXptMS41IDdoM2EuNS41IDAgMSAxIDAgMWgtM2EuNS41IDAgMSAxIDAtMXptMC0yaDJhLjUuNSAwIDAgMSAwIDFoLTJhLjUuNSAwIDAgMSAwLTF6TTggMmwzIDEuOTk1TDEzIDdIOWExIDEgMCAwIDEtMS0xVjJ6IiBpZD0iYSIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8%2BPC9nPjwvc3ZnPg%3D%3D" alt="LinkToDocs"/></a>
</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"/></a>
<img src="https://img.shields.io/badge/Version-v0.23.1-orange.svg" alt="Version"/>
<a href="https://travis-ci.org/LeoVen/C-Macro-Collections"><img src="https://travis-ci.org/LeoVen/C-Macro-Collections.svg?branch=master" alt="travis-ci"/></a>
<a href="https://codecov.io/gh/LeoVen/C-Macro-Collections"><img src="https://codecov.io/gh/LeoVen/C-Macro-Collections/branch/master/graph/badge.svg" alt="codecov"/></a>
<img src="https://github.com/LeoVen/C-Macro-Collections/workflows/Test%20Suit/badge.svg?branch=master" alt="test_suit"/>
</p>
<p>The C Macro Collections Library is a compilation of macros that can be used to generate common data structures for any desired type. These data structures are <a href="https://en.wikipedia.org/wiki/Type_safety">type safe</a> and are powered with many features (see Features section).</p>
<p>The documentation is currently being written in hopes that in the future it can be used to help you get to know better this amazing C library.</p>
+1193 -90
View File
File diff suppressed because it is too large. Load diff
+237
View File
@@ -0,0 +1,237 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>sac - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html" class="active"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#sac" id="sac">SAC</a></h1>
<p>The Statically Allocated Collections. These collections have a fixed size. Its size is one of the parameters during macro expansion, producing a C array.</p>
<h2><a class="header" href="#cmc-vs-sac" id="cmc-vs-sac">CMC vs. SAC</a></h2>
<p>The <code>cmc</code> collections hold their data either with nodes or a buffer that can be reallocated. The <code>sac</code> collections only have an array with fixed size and don't perform any allocation on the heap.</p>
<pre><code class="language-c">// A CMC List
struct List
{
T *buffer;
/* Other fields */
};
// A SAC List
struct List
{
T buffer[SIZE];
/* Other fields */
};
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../dev/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../utl/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../dev/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../utl/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+1 -1
View File
@@ -1 +1 @@
Object.assign(window.search, {"doc_urls":["Introduction/introduction.html#introduction","Introduction/why_this_library.html#why-this-library","Introduction/how_to_install.html#how-to-install","Introduction/library_structure.html#library-structure","Introduction/library_structure.html#cmc","Introduction/library_structure.html#dev","Introduction/library_structure.html#sac","Introduction/library_structure.html#utl","Introduction/library_structure.html#macro_collectionsh","Introduction/understanding_the_library.html#understanding-the-library","Introduction/understanding_the_library.html#sname","Introduction/understanding_the_library.html#pfx","Introduction/understanding_the_library.html#k","Introduction/understanding_the_library.html#v","Introduction/understanding_the_library.html#summarizing","Introduction/how_to_use_the_library.html#how-to-use-the-library","Features/features.html#features","Features/two_way_iterators.html#two-way-iterators","Features/custom_allocation.html#custom-allocation","Features/callbacks.html#callbacks","Features/functions_table.html#functions-table","Features/functions_table.html#cmp","Features/functions_table.html#cpy","Features/functions_table.html#str","Features/functions_table.html#free","Features/functions_table.html#hash","Features/functions_table.html#pri","Overview/overview.html#collections-overview","utl/utl.html#utl","utl/assert.h/index.html#asserth","utl/assert.h/overview.html#overview","utl/assert.h/overview.html#single-value-assertion-macros","utl/assert.h/overview.html#array-assertion-macros","utl/assert.h/overview.html#dtype","utl/assert.h/single_value_assertion.html#single-value-assertion-macros","utl/assert.h/single_value_assertion.html#cmc_assert_state","utl/assert.h/single_value_assertion.html#cmc_assert","utl/assert.h/single_value_assertion.html#parameters","utl/assert.h/single_value_assertion.html#cmc_assert_equals","utl/assert.h/array_assertion.html#array-assertion","utl/foreach.html#foreachmd","utl/foreach.html#parameters","utl/log.html#logh","utl/test.html#testh","utl/timer.html#timerh","Examples/examples.html#minimal-example","Examples/examples.html#include-headers","Examples/examples.html#generating-a-list","Examples/examples.html#initializing-and-adding-elements","Examples/examples.html#iteration","Examples/examples.html#freeing-resources","Examples/examples.html#compile-and-run","Examples/examples.html#conclusion"],"index":{"documentStore":{"docInfo":{"0":{"body":44,"breadcrumbs":1,"title":1},"1":{"body":122,"breadcrumbs":2,"title":1},"10":{"body":45,"breadcrumbs":2,"title":1},"11":{"body":46,"breadcrumbs":2,"title":1},"12":{"body":11,"breadcrumbs":2,"title":1},"13":{"body":7,"breadcrumbs":2,"title":1},"14":{"body":22,"breadcrumbs":2,"title":1},"15":{"body":12,"breadcrumbs":3,"title":2},"16":{"body":15,"breadcrumbs":1,"title":1},"17":{"body":38,"breadcrumbs":4,"title":3},"18":{"body":20,"breadcrumbs":3,"title":2},"19":{"body":45,"breadcrumbs":2,"title":1},"2":{"body":65,"breadcrumbs":2,"title":1},"20":{"body":22,"breadcrumbs":3,"title":2},"21":{"body":44,"breadcrumbs":2,"title":1},"22":{"body":32,"breadcrumbs":2,"title":1},"23":{"body":20,"breadcrumbs":2,"title":1},"24":{"body":20,"breadcrumbs":2,"title":1},"25":{"body":12,"breadcrumbs":2,"title":1},"26":{"body":184,"breadcrumbs":2,"title":1},"27":{"body":244,"breadcrumbs":2,"title":2},"28":{"body":18,"breadcrumbs":1,"title":1},"29":{"body":72,"breadcrumbs":2,"title":1},"3":{"body":36,"breadcrumbs":3,"title":2},"30":{"body":0,"breadcrumbs":3,"title":1},"31":{"body":9,"breadcrumbs":6,"title":4},"32":{"body":4,"breadcrumbs":5,"title":3},"33":{"body":36,"breadcrumbs":3,"title":1},"34":{"body":0,"breadcrumbs":6,"title":4},"35":{"body":43,"breadcrumbs":3,"title":1},"36":{"body":6,"breadcrumbs":3,"title":1},"37":{"body":5,"breadcrumbs":3,"title":1},"38":{"body":1,"breadcrumbs":3,"title":1},"39":{"body":0,"breadcrumbs":4,"title":2},"4":{"body":4,"breadcrumbs":2,"title":1},"40":{"body":21,"breadcrumbs":2,"title":1},"41":{"body":13,"breadcrumbs":2,"title":1},"42":{"body":2,"breadcrumbs":2,"title":1},"43":{"body":4,"breadcrumbs":2,"title":1},"44":{"body":4,"breadcrumbs":2,"title":1},"45":{"body":15,"breadcrumbs":2,"title":2},"46":{"body":15,"breadcrumbs":2,"title":2},"47":{"body":59,"breadcrumbs":2,"title":2},"48":{"body":78,"breadcrumbs":3,"title":3},"49":{"body":111,"breadcrumbs":1,"title":1},"5":{"body":18,"breadcrumbs":2,"title":1},"50":{"body":43,"breadcrumbs":2,"title":2},"51":{"body":54,"breadcrumbs":2,"title":2},"52":{"body":26,"breadcrumbs":1,"title":1},"6":{"body":19,"breadcrumbs":2,"title":1},"7":{"body":13,"breadcrumbs":2,"title":1},"8":{"body":8,"breadcrumbs":2,"title":1},"9":{"body":29,"breadcrumbs":3,"title":2}},"docs":{"0":{"body":"Header only, macro generated, generic and type-safe Collections in C. The C Macro Collections Library is a compilation of macros that can be used to generate common data structures for any desired type. These data structures are type safe and are powered with many featuresLine truncated
Object.assign(window.search, {"doc_urls":["Introduction/introduction.html#introduction","Introduction/why_this_library.html#why-this-library","Introduction/how_to_install.html#how-to-install","Introduction/library_structure.html#library-structure","Introduction/library_structure.html#cmc","Introduction/library_structure.html#dev","Introduction/library_structure.html#sac","Introduction/library_structure.html#utl","Introduction/library_structure.html#macro_collectionsh","Introduction/understanding_the_library.html#understanding-the-library","Introduction/understanding_the_library.html#sname","Introduction/understanding_the_library.html#pfx","Introduction/understanding_the_library.html#k","Introduction/understanding_the_library.html#v","Introduction/understanding_the_library.html#summarizing","Introduction/how_to_use_the_library.html#how-to-use-the-library","Overview/index.html#overview","Overview/collections_overview.html#collections-overview","Overview/features_overview.html#features-overview","Overview/files_overview.html#files-overview","cor/index.html#cor","cor/callbacks/index.html#callbacks","cor/callbacks/index.html#cmc_callbacks","cor/callbacks/index.html#example","cor/custom_allocation/index.html#custom-allocation","cor/custom_allocation/index.html#cmc_alloc_node","cor/custom_allocation/index.html#cmc_alloc_node_default","cor/custom_allocation/index.html#example","cor/error_codes/index.html#error-codes","cor/error_codes/index.html#cmc_flags","cor/error_codes/index.html#cmc_flags_to_str","cor/error_codes/index.html#example","cor/functions_table/index.html#functions-table","cor/functions_table/index.html#cmp","cor/functions_table/index.html#cpy","cor/functions_table/index.html#str","cor/functions_table/index.html#free","cor/functions_table/index.html#hash","cor/functions_table/index.html#pri","cor/iterators/index.html#iterators","cmc/index.html#cmc","cmc/index.html#quick-example","cmc/bitset.h/index.html#bitseth","cmc/bitset.h/index.html#bitset-implementation","cmc/bitset.h/index.html#bitset-generation-macros","cmc/bitset.h/index.html#bitset-structures","cmc/bitset.h/index.html#struct-sname","cmc/bitset.h/index.html#struct-sname_iter","cmc/bitset.h/index.html#cmc_bitset_word","cmc/bitset.h/index.html#callbacks","cmc/bitset.h/index.html#functions-table","cmc/deque.h/index.html#dequeh","cmc/deque.h/index.html#deque-implementation","cmc/deque.h/index.html#deque-generation-macros","cmc/deque.h/index.html#deque-structures","cmc/deque.h/index.html#struct-sname","cmc/deque.h/index.html#struct-sname_fval","cmc/deque.h/index.html#struct-sname_iter","cmc/deque.h/index.html#callbacks","cmc/deque.h/index.html#functions-table","cmc/deque.h/functions.html#index","cmc/deque.h/functions.html#_new","cmc/deque.h/functions.html#_new_custom","dev/index.html#dev","sac/index.html#sac","sac/index.html#cmc-vs-sac","utl/index.html#utl","utl/index.html#contents","utl/assert.h/index.html#asserth","utl/assert.h/index.html#printed-messages","utl/assert.h/index.html#cmc_assert_state","utl/assert.h/index.html#dtype","utl/assert.h/overview.html#overview","utl/assert.h/overview.html#single-value-assertion-macros","utl/assert.h/overview.html#array-assertion-macros","utl/assert.h/valued_assertions.html#valued-assertion-macros","utl/assert.h/valued_assertions.html#contents","utl/assert.h/valued_assertions.html#cmc_assert","utl/assert.h/valued_assertions.html#cmc_assert_equals","utl/assert.h/valued_assertions.html#cmc_assert_not_equals","utl/assert.h/valued_assertions.html#cmc_assert_greater","utl/assert.h/valued_assertions.html#cmc_assert_greater_equals","utl/assert.h/valued_assertions.html#cmc_assert_lesser","utl/assert.h/valued_assertions.html#cmc_assert_lesser_equals","utl/assert.h/valued_assertions.html#cmc_assert_in_range","utl/assert.h/valued_assertions.html#cmc_assert_not_in_range","utl/assert.h/generic_assertions.html#generic-assertion-macros","utl/assert.h/generic_assertions.html#contents","utl/assert.h/generic_assertions.html#cmc_assert_array_equals_any","utl/assert.h/generic_assertions.html#cmc_assert_array_within_any","utl/assert.h/generic_assertions.html#cmc_assert_array_outside_any","utl/assert.h/generic_assertions.html#cmc_assert_array_sorted_any","utl/foreach.h/index.html#foreachh","utl/foreach.h/index.html#cmc_foreach","utl/foreach.h/index.html#cmc_foreach_rev","utl/foreach.h/index.html#example","utl/futils.h/index.html#futilsh","utl/log.h/index.html#logh","utl/log.h/index.html#cmc_log_type","utl/log.h/index.html#cmc_log_color","utl/log.h/log_functions.html#log-functions","utl/log.h/log_functions.html#cmc_log_trace","utl/log.h/log_functions.html#cmc_log_debug","utl/log.h/log_functions.html#cmc_log_info","utl/log.h/log_functions.html#cmc_log_warn","utl/log.h/log_functions.html#cmc_log_error","utl/log.h/log_functions.html#cmc_log_fatal","utl/log.h/configuration.html#configuration","utl/log.h/configuration.html#cmc_log_config","utl/log.h/configuration.html#log-level","utl/log.h/meanings.html#meanings","utl/test.h/index.htmlLine truncated
+1 -1
View File
@@ -1 +1 @@
{"doc_urls":["Introduction/introduction.html#introduction","Introduction/why_this_library.html#why-this-library","Introduction/how_to_install.html#how-to-install","Introduction/library_structure.html#library-structure","Introduction/library_structure.html#cmc","Introduction/library_structure.html#dev","Introduction/library_structure.html#sac","Introduction/library_structure.html#utl","Introduction/library_structure.html#macro_collectionsh","Introduction/understanding_the_library.html#understanding-the-library","Introduction/understanding_the_library.html#sname","Introduction/understanding_the_library.html#pfx","Introduction/understanding_the_library.html#k","Introduction/understanding_the_library.html#v","Introduction/understanding_the_library.html#summarizing","Introduction/how_to_use_the_library.html#how-to-use-the-library","Features/features.html#features","Features/two_way_iterators.html#two-way-iterators","Features/custom_allocation.html#custom-allocation","Features/callbacks.html#callbacks","Features/functions_table.html#functions-table","Features/functions_table.html#cmp","Features/functions_table.html#cpy","Features/functions_table.html#str","Features/functions_table.html#free","Features/functions_table.html#hash","Features/functions_table.html#pri","Overview/overview.html#collections-overview","utl/utl.html#utl","utl/assert.h/index.html#asserth","utl/assert.h/overview.html#overview","utl/assert.h/overview.html#single-value-assertion-macros","utl/assert.h/overview.html#array-assertion-macros","utl/assert.h/overview.html#dtype","utl/assert.h/single_value_assertion.html#single-value-assertion-macros","utl/assert.h/single_value_assertion.html#cmc_assert_state","utl/assert.h/single_value_assertion.html#cmc_assert","utl/assert.h/single_value_assertion.html#parameters","utl/assert.h/single_value_assertion.html#cmc_assert_equals","utl/assert.h/array_assertion.html#array-assertion","utl/foreach.html#foreachmd","utl/foreach.html#parameters","utl/log.html#logh","utl/test.html#testh","utl/timer.html#timerh","Examples/examples.html#minimal-example","Examples/examples.html#include-headers","Examples/examples.html#generating-a-list","Examples/examples.html#initializing-and-adding-elements","Examples/examples.html#iteration","Examples/examples.html#freeing-resources","Examples/examples.html#compile-and-run","Examples/examples.html#conclusion"],"index":{"documentStore":{"docInfo":{"0":{"body":44,"breadcrumbs":1,"title":1},"1":{"body":122,"breadcrumbs":2,"title":1},"10":{"body":45,"breadcrumbs":2,"title":1},"11":{"body":46,"breadcrumbs":2,"title":1},"12":{"body":11,"breadcrumbs":2,"title":1},"13":{"body":7,"breadcrumbs":2,"title":1},"14":{"body":22,"breadcrumbs":2,"title":1},"15":{"body":12,"breadcrumbs":3,"title":2},"16":{"body":15,"breadcrumbs":1,"title":1},"17":{"body":38,"breadcrumbs":4,"title":3},"18":{"body":20,"breadcrumbs":3,"title":2},"19":{"body":45,"breadcrumbs":2,"title":1},"2":{"body":65,"breadcrumbs":2,"title":1},"20":{"body":22,"breadcrumbs":3,"title":2},"21":{"body":44,"breadcrumbs":2,"title":1},"22":{"body":32,"breadcrumbs":2,"title":1},"23":{"body":20,"breadcrumbs":2,"title":1},"24":{"body":20,"breadcrumbs":2,"title":1},"25":{"body":12,"breadcrumbs":2,"title":1},"26":{"body":184,"breadcrumbs":2,"title":1},"27":{"body":244,"breadcrumbs":2,"title":2},"28":{"body":18,"breadcrumbs":1,"title":1},"29":{"body":72,"breadcrumbs":2,"title":1},"3":{"body":36,"breadcrumbs":3,"title":2},"30":{"body":0,"breadcrumbs":3,"title":1},"31":{"body":9,"breadcrumbs":6,"title":4},"32":{"body":4,"breadcrumbs":5,"title":3},"33":{"body":36,"breadcrumbs":3,"title":1},"34":{"body":0,"breadcrumbs":6,"title":4},"35":{"body":43,"breadcrumbs":3,"title":1},"36":{"body":6,"breadcrumbs":3,"title":1},"37":{"body":5,"breadcrumbs":3,"title":1},"38":{"body":1,"breadcrumbs":3,"title":1},"39":{"body":0,"breadcrumbs":4,"title":2},"4":{"body":4,"breadcrumbs":2,"title":1},"40":{"body":21,"breadcrumbs":2,"title":1},"41":{"body":13,"breadcrumbs":2,"title":1},"42":{"body":2,"breadcrumbs":2,"title":1},"43":{"body":4,"breadcrumbs":2,"title":1},"44":{"body":4,"breadcrumbs":2,"title":1},"45":{"body":15,"breadcrumbs":2,"title":2},"46":{"body":15,"breadcrumbs":2,"title":2},"47":{"body":59,"breadcrumbs":2,"title":2},"48":{"body":78,"breadcrumbs":3,"title":3},"49":{"body":111,"breadcrumbs":1,"title":1},"5":{"body":18,"breadcrumbs":2,"title":1},"50":{"body":43,"breadcrumbs":2,"title":2},"51":{"body":54,"breadcrumbs":2,"title":2},"52":{"body":26,"breadcrumbs":1,"title":1},"6":{"body":19,"breadcrumbs":2,"title":1},"7":{"body":13,"breadcrumbs":2,"title":1},"8":{"body":8,"breadcrumbs":2,"title":1},"9":{"body":29,"breadcrumbs":3,"title":2}},"docs":{"0":{"body":"Header only, macro generated, generic and type-safe Collections in C. The C Macro Collections Library is a compilation of macros that can be used to generate common data structures for any desired type. These data structures are type safe and are powered with many features (see Features section). The Line truncated
{"doc_urls":["Introduction/introduction.html#introduction","Introduction/why_this_library.html#why-this-library","Introduction/how_to_install.html#how-to-install","Introduction/library_structure.html#library-structure","Introduction/library_structure.html#cmc","Introduction/library_structure.html#dev","Introduction/library_structure.html#sac","Introduction/library_structure.html#utl","Introduction/library_structure.html#macro_collectionsh","Introduction/understanding_the_library.html#understanding-the-library","Introduction/understanding_the_library.html#sname","Introduction/understanding_the_library.html#pfx","Introduction/understanding_the_library.html#k","Introduction/understanding_the_library.html#v","Introduction/understanding_the_library.html#summarizing","Introduction/how_to_use_the_library.html#how-to-use-the-library","Overview/index.html#overview","Overview/collections_overview.html#collections-overview","Overview/features_overview.html#features-overview","Overview/files_overview.html#files-overview","cor/index.html#cor","cor/callbacks/index.html#callbacks","cor/callbacks/index.html#cmc_callbacks","cor/callbacks/index.html#example","cor/custom_allocation/index.html#custom-allocation","cor/custom_allocation/index.html#cmc_alloc_node","cor/custom_allocation/index.html#cmc_alloc_node_default","cor/custom_allocation/index.html#example","cor/error_codes/index.html#error-codes","cor/error_codes/index.html#cmc_flags","cor/error_codes/index.html#cmc_flags_to_str","cor/error_codes/index.html#example","cor/functions_table/index.html#functions-table","cor/functions_table/index.html#cmp","cor/functions_table/index.html#cpy","cor/functions_table/index.html#str","cor/functions_table/index.html#free","cor/functions_table/index.html#hash","cor/functions_table/index.html#pri","cor/iterators/index.html#iterators","cmc/index.html#cmc","cmc/index.html#quick-example","cmc/bitset.h/index.html#bitseth","cmc/bitset.h/index.html#bitset-implementation","cmc/bitset.h/index.html#bitset-generation-macros","cmc/bitset.h/index.html#bitset-structures","cmc/bitset.h/index.html#struct-sname","cmc/bitset.h/index.html#struct-sname_iter","cmc/bitset.h/index.html#cmc_bitset_word","cmc/bitset.h/index.html#callbacks","cmc/bitset.h/index.html#functions-table","cmc/deque.h/index.html#dequeh","cmc/deque.h/index.html#deque-implementation","cmc/deque.h/index.html#deque-generation-macros","cmc/deque.h/index.html#deque-structures","cmc/deque.h/index.html#struct-sname","cmc/deque.h/index.html#struct-sname_fval","cmc/deque.h/index.html#struct-sname_iter","cmc/deque.h/index.html#callbacks","cmc/deque.h/index.html#functions-table","cmc/deque.h/functions.html#index","cmc/deque.h/functions.html#_new","cmc/deque.h/functions.html#_new_custom","dev/index.html#dev","sac/index.html#sac","sac/index.html#cmc-vs-sac","utl/index.html#utl","utl/index.html#contents","utl/assert.h/index.html#asserth","utl/assert.h/index.html#printed-messages","utl/assert.h/index.html#cmc_assert_state","utl/assert.h/index.html#dtype","utl/assert.h/overview.html#overview","utl/assert.h/overview.html#single-value-assertion-macros","utl/assert.h/overview.html#array-assertion-macros","utl/assert.h/valued_assertions.html#valued-assertion-macros","utl/assert.h/valued_assertions.html#contents","utl/assert.h/valued_assertions.html#cmc_assert","utl/assert.h/valued_assertions.html#cmc_assert_equals","utl/assert.h/valued_assertions.html#cmc_assert_not_equals","utl/assert.h/valued_assertions.html#cmc_assert_greater","utl/assert.h/valued_assertions.html#cmc_assert_greater_equals","utl/assert.h/valued_assertions.html#cmc_assert_lesser","utl/assert.h/valued_assertions.html#cmc_assert_lesser_equals","utl/assert.h/valued_assertions.html#cmc_assert_in_range","utl/assert.h/valued_assertions.html#cmc_assert_not_in_range","utl/assert.h/generic_assertions.html#generic-assertion-macros","utl/assert.h/generic_assertions.html#contents","utl/assert.h/generic_assertions.html#cmc_assert_array_equals_any","utl/assert.h/generic_assertions.html#cmc_assert_array_within_any","utl/assert.h/generic_assertions.html#cmc_assert_array_outside_any","utl/assert.h/generic_assertions.html#cmc_assert_array_sorted_any","utl/foreach.h/index.html#foreachh","utl/foreach.h/index.html#cmc_foreach","utl/foreach.h/index.html#cmc_foreach_rev","utl/foreach.h/index.html#example","utl/futils.h/index.html#futilsh","utl/log.h/index.html#logh","utl/log.h/index.html#cmc_log_type","utl/log.h/index.html#cmc_log_color","utl/log.h/log_functions.html#log-functions","utl/log.h/log_functions.html#cmc_log_trace","utl/log.h/log_functions.html#cmc_log_debug","utl/log.h/log_functions.html#cmc_log_info","utl/log.h/log_functions.html#cmc_log_warn","utl/log.h/log_functions.html#cmc_log_error","utl/log.h/log_functions.html#cmc_log_fatal","utl/log.h/configuration.html#configuration","utl/log.h/configuration.html#cmc_log_config","utl/log.h/configuration.html#log-level","utl/log.h/meanings.html#meanings","utl/test.h/index.html#testh","utl/test.h/index.htmLine truncated
+280
View File
@@ -0,0 +1,280 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Generic Assertions - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html" class="active"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#generic-assertion-macros" id="generic-assertion-macros">Generic Assertion Macros</a></h1>
<h2><a class="header" href="#contents" id="contents">Contents</a></h2>
<ul>
<li><a href="#cmc_assert_array_equals_any">cmc_assert_array_equals_any</a></li>
<li><a href="#cmc_assert_array_within_any">cmc_assert_array_within_any</a></li>
<li><a href="#cmc_assert_array_outside_any">cmc_assert_array_outside_any</a></li>
<li><a href="#cmc_assert_array_sorted_any">cmc_assert_array_sorted_any</a></li>
</ul>
<h2><a class="header" href="#cmc_assert_array_equals_any" id="cmc_assert_array_equals_any">cmc_assert_array_equals_any</a></h2>
<p>Assert that two arrays are equal element by element. <code>from_index</code> and <code>to_index</code> are both inclusive.</p>
<pre><code class="language-c">#define cmc_assert_array_equals_any(dtype, array1, array2, comparator, \
from_index, to_index)
</code></pre>
<ul>
<li><code>dtype</code> - The type of the array. Can be of any data type.</li>
<li><code>array1</code> - First array to be compared</li>
<li><code>array2</code> - Second array to be compared</li>
<li><code>comparator</code> - A comparator function pointer that has two <code>dtype</code> arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second</li>
<li><code>from_index</code> - First index from both arrays to compare (inclusive)</li>
<li><code>to_index</code> - Last index from both arrays to compare (inclusive)</li>
</ul>
<h2><a class="header" href="#cmc_assert_array_within_any" id="cmc_assert_array_within_any">cmc_assert_array_within_any</a></h2>
<p>Assert that each element in the array are within a certain boundary. Both ends are inclusive.</p>
<pre><code class="language-c">#define cmc_assert_array_within_any(dtype, array, comparator, lower_bound, \
upper_bound, from_index, to_index)
</code></pre>
<ul>
<li><code>dtype</code> - The type of the array. Can be of any data type</li>
<li><code>array</code> - Array to be checked if its elements are within a given range</li>
<li><code>comparator</code> - A comparator function pointer that has two <code>dtype</code> arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second</li>
<li><code>lower_bound</code> - Smallest value of the given range</li>
<li><code>upper_bound</code> - Highest value of the given range</li>
<li><code>from_index</code> - First index from the array to compare (inclusive)</li>
<li><code>to_index</code> - Last index from the array to compare (inclusive)</li>
</ul>
<h2><a class="header" href="#cmc_assert_array_outside_any" id="cmc_assert_array_outside_any">cmc_assert_array_outside_any</a></h2>
<p>Assert that each element in the array are outside of a certain boundary. Both ends are inclusive.</p>
<pre><code class="language-c">#define cmc_assert_array_outside_any(dtype, array, comparator, lower_bound, \
upper_bound, from_index, to_index)
</code></pre>
<ul>
<li><code>dtype</code> - The type of the array. Can be of any data type</li>
<li><code>array</code> - Array to be checked if its elements are within a given range</li>
<li><code>comparator</code> - A comparator function pointer that has two <code>dtype</code> arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second</li>
<li><code>lower_bound</code> - Smallest value of the given range</li>
<li><code>upper_bound</code> - Highest value of the given range</li>
<li><code>from_index</code> - First index from the array to compare (inclusive)</li>
<li><code>to_index</code> - Last index from the array to compare (inclusive)</li>
</ul>
<h2><a class="header" href="#cmc_assert_array_sorted_any" id="cmc_assert_array_sorted_any">cmc_assert_array_sorted_any</a></h2>
<p>Asserts that an array is sorted.</p>
<pre><code class="language-c">#define cmc_assert_array_sorted_any(dtype, array, comparator, from_index, \
to_index)
</code></pre>
<ul>
<li><code>dtype</code> - The type of the array. Can be of any data type</li>
<li><code>array</code> - Array to be checked if it is sorted</li>
<li><code>comparator</code> - A comparator function pointer that has two <code>dtype</code> arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second</li>
<li><code>from_index</code> - First index from the array to compare (inclusive)</li>
<li><code>to_index</code> - Last index from the array to compare (inclusive)</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/assert.h/valued_assertions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/foreach.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/assert.h/valued_assertions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/foreach.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+58 -5
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html" class="active"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html" class="active"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -151,15 +151,68 @@
<h1><a class="header" href="#asserth" id="asserth">assert.h</a></h1>
<p>Definition of many typed non-abortive assertions. Every assertion that fails will print a message to <code>stderr</code> but will not abort the program execution. The macro parameters are first assigned to a temporary variable of the specified <code>dtype</code> in order to generate warnings from the compiler in case of type mismatch.</p>
<p>The advantage of these typed macros is that when an assertion fails, it is possible to print to <code>stderr</code> the actual value that was passed to the function and check the expected result(s) all in one message.</p>
<p>There are assertions that work with a single value to be tested and others that work with arrays. Single value assertions work with a selected list of <code>dtype</code>, while the assertion with arrays work with any <code>dtype</code> that is a valid data type.</p>
<p>The macro parameters can be an lvalue or an rvalue.</p>
<p>There are assertions that work with <a href="valued_assertions.html">predefined values</a> and others that work with <a href="generic_assertions.html">generic values</a>. Valued assertions work with a selected list of <code>dtype</code> (see further below), while the generic assertions work with any data type.</p>
<p>The macro parameters can be an <em>lvalue</em> or an <em>rvalue</em> because the parameters will be first assigned to local variables of the selected data type. Then, these local variables will be tested for whichever test that needs to be checked.</p>
<p>Assigning the macro parameter to a local variable can be useful. These local variables will be of type <code>dtype</code> and if the parameters don't match that type a warning will pop up.</p>
<p>Ever assertion is inside a block of <code>do { } while (0)</code>.</p>
<h2><a class="header" href="#printed-messages" id="printed-messages">Printed Messages</a></h2>
<p>Whenever an assertion fails, a message will be printed to <code>stderr</code>. The message will look something like this:</p>
<pre><code>Assertion Failed at FILE:FUNCTION:LINE for { ACTUAL }: DETAILS
</code></pre>
<p>The first information is the file where that assertion failed. Then the function name and the line number. Then in place of <code>ACTUAL</code>, a stringified version of the <code>actual</code> parameter, which is the variable being checked in the assertion, will be printed.</p>
<p>In <code>DETAILS</code> is where more information about the assertion will be printed. This is the most useful part of these macros. In here, the actual value of the variable will be printed along with the expected value or range or lower bound, etc. <strong>In here you will be able to debug your application to check the expected value(s) against the actual one.</strong></p>
<p><strong>Example</strong></p>
<pre><code class="language-c">#include &quot;utl/assert.h&quot;
void is_one_hundred(int variable)
{
cmc_assert_equals(int32_t, 100, variable);
}
int main(void)
{
int my_var = 9;
is_one_hundred(my_var);
}
</code></pre>
<p>This will print the following message:</p>
<p><code>Assertion Failed at main.c:is_one_hundred:5 for { variable }: Expected: 100 Actual: 9</code></p>
<h2><a class="header" href="#cmc_assert_state" id="cmc_assert_state">cmc_assert_state</a></h2>
<p>This is a global variable that can be used to test if all assertions passed. If any assertion fails, this variable will be set to <code>false</code>. If an assertion passes this variable will <strong>not</strong> be set back to <code>true</code>. If you wish to, you can set the state back to <code>true</code> manually.</p>
<pre><code class="language-c">static bool cmc_assert_state = true;
</code></pre>
<p>This variable is used in <a href="../test.h/index.html">test.h</a> utility to automatically pass or fail a unit test. Once the unit test finishes, this variable is set back to <code>true</code> so that another unit test may follow.</p>
<h2><a class="header" href="#dtype" id="dtype">dtype</a></h2>
<p>These are the data types supported by the Valued Assertion macros:</p>
<ul>
<li><code>int8_t</code></li>
<li><code>int16_t</code></li>
<li><code>int32_t</code></li>
<li><code>int64_t</code></li>
<li><code>uint8_t</code></li>
<li><code>uint16_t</code></li>
<li><code>uint32_t</code></li>
<li><code>uint64_t</code></li>
<li><code>intmax_t</code></li>
<li><code>uintmax_t</code></li>
<li><code>size_t</code></li>
<li><code>float</code></li>
<li><code>double</code></li>
</ul>
<p>The following two are only accepted by <code>cmc_assert_equals</code> and <code>cmc_assert_not_equals</code>:</p>
<ul>
<li><code>ptr</code></li>
<li><code>bool</code></li>
</ul>
<p>Note that <code>ptr</code> is used for any pointers. They are first casted to <code>void *</code> and then their address is compared.</p>
<p>Note that bool will be expanded to <code>_Bool</code>.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/utl.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../../utl/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
@@ -177,7 +230,7 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/utl.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../../utl/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
+16 -39
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html" class="active"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html" class="active"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -151,46 +151,23 @@
<h1><a class="header" href="#overview" id="overview">Overview</a></h1>
<h2><a class="header" href="#single-value-assertion-macros" id="single-value-assertion-macros">Single Value Assertion Macros</a></h2>
<ul>
<li>cmc_assert</li>
<li>cmc_assert_equals</li>
<li>cmc_assert_not_equals</li>
<li>cmc_assert_greater</li>
<li>cmc_assert_greater_equals</li>
<li>cmc_assert_lesser</li>
<li>cmc_assert_lesser_equals</li>
<li>cmc_assert_in_range</li>
<li>cmc_assert_not_in_range</li>
<li><strong>cmc_assert</strong> - Asserts that an expression evaluates to true;</li>
<li><strong>cmc_assert_equals</strong> - Asserts that a value from type <code>dtype</code> equals another;</li>
<li><strong>cmc_assert_not_equals</strong> - Asserts that value from type <code>dtype</code> does not equals another;</li>
<li><strong>cmc_assert_greater</strong> - Asserts that a value from type <code>dtype</code> is greater than a lower bound;</li>
<li><strong>cmc_assert_greater_equals</strong> - Asserts that a value from type <code>dtpype</code> is greater than or equal to a lower bound;</li>
<li><strong>cmc_assert_lesser</strong> - Asserts that a value from type <code>dtpype</code> is lesser than an upper bound;</li>
<li><strong>cmc_assert_lesser_equals</strong> - Asserts that a value from type <code>dtpype</code> is lesser than or equal to an upper bound;</li>
<li><strong>cmc_assert_in_range</strong> - Asserts that a value from type <code>dtpype</code> is within a certain range;</li>
<li><strong>cmc_assert_not_in_range</strong> - Asserts that a value from type <code>dtpype</code> is outside of a certain range.</li>
</ul>
<h2><a class="header" href="#array-assertion-macros" id="array-assertion-macros">Array Assertion Macros</a></h2>
<ul>
<li>cmc_assert_array_equals_any</li>
<li>cmc_assert_array_within_any</li>
<li>cmc_assert_array_outside_any</li>
<li>cmc_assert_array_sorted_any</li>
<li><strong>cmc_assert_array_equals_any</strong> - Assert that two arrays are equal element by element;</li>
<li><strong>cmc_assert_array_within_any</strong> - Assert that each element in the array are within a bounds;</li>
<li><strong>cmc_assert_array_outside_any</strong> - Assert that each element in the array are out of bounds;</li>
<li><strong>cmc_assert_array_sorted_any</strong> - Assert that the array is sorted.</li>
</ul>
<h2><a class="header" href="#dtype" id="dtype">dtype</a></h2>
<p>These are the data types supported by the single value assertion macros:</p>
<ul>
<li>int8_t</li>
<li>int16_t</li>
<li>int32_t</li>
<li>int64_t</li>
<li>uint8_t</li>
<li>uint16_t</li>
<li>uint32_t</li>
<li>uint64_t</li>
<li>intmax_t</li>
<li>uintmax_t</li>
<li>size_t</li>
<li>float</li>
<li>double</li>
</ul>
<p>The following two are only accepted by <code>cmc_assert_equals</code> and <code>cmc_assert_not_equals</code>:</p>
<ul>
<li>ptr</li>
<li>bool</li>
</ul>
<p>Note that <code>ptr</code> is used for any pointers. They are first casted to <code>void *</code> and then their address is compared.</p>
</main>
@@ -203,7 +180,7 @@
<a rel="next" href="../../utl/assert.h/single_value_assertion.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../../utl/assert.h/valued_assertions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -221,7 +198,7 @@
<a href="../../utl/assert.h/single_value_assertion.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../../utl/assert.h/valued_assertions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
+316
View File
@@ -0,0 +1,316 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Valued Assertions - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html" class="active"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#valued-assertion-macros" id="valued-assertion-macros">Valued Assertion Macros</a></h1>
<h2><a class="header" href="#contents" id="contents">Contents</a></h2>
<ul>
<li><a href="#cmc_assert">cmc_assert</a></li>
<li><a href="#cmc_assert_equals">cmc_assert_equals</a></li>
<li><a href="#cmc_assert_not_equals">cmc_assert_not_equals</a></li>
<li><a href="#cmc_assert_greater">cmc_assert_greater</a></li>
<li><a href="#cmc_assert_greater_equals">cmc_assert_greater_equals</a></li>
<li><a href="#cmc_assert_lesser">cmc_assert_lesser</a></li>
<li><a href="#cmc_assert_lesser_equals">cmc_assert_lesser_equals</a></li>
<li><a href="#cmc_assert_in_range">cmc_assert_in_range</a></li>
<li><a href="#cmc_assert_not_in_range">cmc_assert_not_in_range</a></li>
</ul>
<h2><a class="header" href="#cmc_assert" id="cmc_assert">cmc_assert</a></h2>
<p>Asserts that an <code>expression</code> evaluates to <code>true</code>.</p>
<pre><code class="language-c">#define cmc_assert(expression)
</code></pre>
<p><strong>Parameters</strong></p>
<ul>
<li><code>expression</code> - An expression that needs to be evaluated to true.</li>
</ul>
<h2><a class="header" href="#cmc_assert_equals" id="cmc_assert_equals">cmc_assert_equals</a></h2>
<p>Asserts that a value equals another expected value.</p>
<pre><code class="language-c">#define cmc_assert_equals(dtype, expected, actual)
</code></pre>
<p><strong>Parameters</strong></p>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>expected</code> - The expected value for this assertion</li>
<li><code>actual</code> - A variant that is checked against the expected value</li>
</ul>
<h2><a class="header" href="#cmc_assert_not_equals" id="cmc_assert_not_equals">cmc_assert_not_equals</a></h2>
<p>Asserts that a value does not equal another.</p>
<pre><code class="language-c">#define cmc_assert_not_equals(dtype, not_expected, actual)
</code></pre>
<p><strong>Parameters</strong></p>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>not_expected</code> - The value that is not expected for this assertion</li>
<li><code>actual</code> - A variant that is checked against the not expected value</li>
</ul>
<h2><a class="header" href="#cmc_assert_greater" id="cmc_assert_greater">cmc_assert_greater</a></h2>
<p>Asserts that a value is above a certain lower boundary.</p>
<pre><code class="language-c">#define cmc_assert_greater(dtype, boundary, actual)
</code></pre>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>boundary</code> - The expected lowest possible value (excluded)</li>
<li><code>actual</code> - A variant that is checked against the boundary value</li>
</ul>
<h2><a class="header" href="#cmc_assert_greater_equals" id="cmc_assert_greater_equals">cmc_assert_greater_equals</a></h2>
<p>Asserts that a value is above a certain lower boundary or equal to it.</p>
<pre><code class="language-c">#define cmc_assert_greater_equals(dtype, boundary, actual)
</code></pre>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>boundary</code> - The expected lowest possible value (included)</li>
<li><code>actual</code> - A variant that is checked against the boundary value</li>
</ul>
<h2><a class="header" href="#cmc_assert_lesser" id="cmc_assert_lesser">cmc_assert_lesser</a></h2>
<p>Asserts that a value is below a certain upper boundary.</p>
<pre><code class="language-c">#define cmc_assert_lesser(dtype, boundary, actual)
</code></pre>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>boundary</code> - The expected highest possible value (excluded)</li>
<li><code>actual</code> - A variant that is checked against the boundary value</li>
</ul>
<h2><a class="header" href="#cmc_assert_lesser_equals" id="cmc_assert_lesser_equals">cmc_assert_lesser_equals</a></h2>
<p>Asserts that a value is below a certain upper boundary or equal to it.</p>
<pre><code class="language-c">#define cmc_assert_lesser_equals(dtype, boundary, actual)
</code></pre>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>boundary</code> - The expected highest possible value (excluded)</li>
<li><code>actual</code> - A variant that is checked against the boundary value</li>
</ul>
<h2><a class="header" href="#cmc_assert_in_range" id="cmc_assert_in_range">cmc_assert_in_range</a></h2>
<p>Asserts that a value is within a certain range. Range is inclusive on both ends.</p>
<pre><code class="language-c">#define cmc_assert_in_range(dtype, lower_bound, upper_bound, actual)
</code></pre>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>lower_bound</code> - Smallest value of the expected range</li>
<li><code>upper_bound</code> - Highest value of the expected range</li>
<li><code>actual</code> - A variant that is checked against lower and upper boundaries value</li>
</ul>
<h2><a class="header" href="#cmc_assert_not_in_range" id="cmc_assert_not_in_range">cmc_assert_not_in_range</a></h2>
<p>Asserts that a value is not within a certain range. Range is inclusive on both ends.</p>
<pre><code class="language-c">#define cmc_assert_not_in_range(dtype, lower_bound, upper_bound, actual)
</code></pre>
<ul>
<li><code>dtype</code> - One of the possible data types listed <a href="index.html#dtype">here</a></li>
<li><code>lower_bound</code> - Smallest value of the not expected range</li>
<li><code>upper_bound</code> - Highest value of the not expected range</li>
<li><code>actual</code> - A variant that is checked against lower and upper boundaries value</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/assert.h/overview.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/assert.h/generic_assertions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/assert.h/overview.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/assert.h/generic_assertions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
@@ -11,21 +11,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
@@ -35,7 +35,7 @@
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../";
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html" class="active"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html" class="active"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -116,7 +116,7 @@
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
@@ -148,32 +148,72 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#foreachmd" id="foreachmd">foreach.md</a></h1>
<h1><a class="header" href="#foreachh" id="foreachh">foreach.h</a></h1>
<p>For-Each macros. Since doing a for loop with iterators can be a lot to write, these macros solve that problem. There are two of them:</p>
<ul>
<li><code>CMC_FOREACH</code> - Goes from the beginning of a Collection to the end</li>
<li><code>CMC_FOREAC_REV</code> - Goes from the end of a Collection to the beginning</li>
</ul>
<h2><a class="header" href="#parameters" id="parameters">Parameters</a></h2>
<h2><a class="header" href="#cmc_foreach" id="cmc_foreach">CMC_FOREACH</a></h2>
<pre><code class="language-c">#define CMC_FOREACH(PFX, SNAME, ITERNAME, TARGET)
</code></pre>
<ul>
<li><code>PFX</code> - Functions prefix</li>
<li><code>SNAME</code> - Struct name</li>
<li><code>ITERNAME</code> - Iterator variable name</li>
<li><code>TARGET</code> - Target variable</li>
<li><code>TARGET</code> - Target collection variable name</li>
</ul>
<h2><a class="header" href="#cmc_foreach_rev" id="cmc_foreach_rev">CMC_FOREACH_REV</a></h2>
<pre><code class="language-c">#define CMC_FOREACH_REV(PFX, SNAME, ITERNAME, TARGET)
</code></pre>
<ul>
<li><code>PFX</code> - Functions prefix</li>
<li><code>SNAME</code> - Struct name</li>
<li><code>ITERNAME</code> - Iterator variable name</li>
<li><code>TARGET</code> - Target collection variable name</li>
</ul>
<h2><a class="header" href="#example" id="example">Example</a></h2>
<pre><code class="language-c">#include &quot;cmc/list.h&quot;
#include &quot;utl/foreach.h&quot;
CMC_GENERATE_LIST(i32l, i32list, int32_t)
int main(void)
{
struct i32list *list = i32l_new(100, &amp;(struct i32list_fval) { NULL });
for (int i = 0; i &lt; 100; i++)
i32l_push_back(list, i);
CMC_FOREACH(i32l, i32list, it, list)
{
int value = i32l_iter_value(&amp;it);
size_t index = i32l_iter_index(&amp;it);
if (index == 0)
printf(&quot;[ %d, &quot;, value);
else if (index == i32l_count(list) - 1)
printf(&quot;%d ]\n&quot;, value);
else
printf(&quot;%d, &quot;, value);
}
i32l_free(list);
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../utl/assert.h/array_assertion.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../../utl/assert.h/generic_assertions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../utl/log.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../../utl/futils.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -185,13 +225,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../utl/assert.h/array_assertion.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../../utl/assert.h/generic_assertions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../utl/log.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../../utl/futils.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -214,14 +254,14 @@
<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../book.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
+293
View File
@@ -0,0 +1,293 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>futils.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html" class="active"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#futilsh" id="futilsh">futils.h</a></h1>
<p>Contains common functions that can be used by Functions Table, instead of writing another one every time.</p>
<p>A quick list of functions present in this file:</p>
<table><thead><tr><th>cmp</th></tr></thead><tbody>
<tr><td><code>static inline int cmc_i64_cmp(int64_t x1, int64_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_i32_cmp(int32_t x1, int32_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_i16_cmp(int16_t x1, int16_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_i8_cmp(int8_t x1, int8_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_u64_cmp(uint64_t x1, uint64_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_u32_cmp(uint32_t x1, uint32_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_u16_cmp(uint16_t x1, uint16_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_u8_cmp(uint8_t x1, uint8_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_size_cmp(size_t x1, size_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_imax_cmp(intmax_t x1, intmax_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_umax_cmp(uintmax_t x1, uintmax_t x2);</code></td></tr>
<tr><td><code>static inline int cmc_float_cmp(float x1, float x2);</code></td></tr>
<tr><td><code>static inline int cmc_double_cmp(double x1, double x2);</code></td></tr>
<tr><td><code>static inline int cmc_str_cmp(char *ch1, char *ch2);</code></td></tr>
</tbody></table>
<br>
<br>
<table><thead><tr><th>cpy</th></tr></thead><tbody>
<tr><td><code>static inline char *cmc_str_cpy(char *str);</code></td></tr>
</tbody></table>
<br>
<br>
<table><thead><tr><th>str</th></tr></thead><tbody>
<tr><td><code>static inline bool cmc_i8_str(FILE *file, int8_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_i16_str(FILE *file, int16_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_i32_str(FILE *file, int32_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_i64_str(FILE *file, int64_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_u8_str(FILE *file, uint8_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_u16_str(FILE *file, uint16_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_u32_str(FILE *file, uint32_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_u64_str(FILE *file, uint64_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_size_str(FILE *file, size_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_imax_str(FILE *file, intmax_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_umax_str(FILE *file, uintmax_t element);</code></td></tr>
<tr><td><code>static inline bool cmc_float_str(FILE *file, float element);</code></td></tr>
<tr><td><code>static inline bool cmc_double_str(FILE *file, double element);</code></td></tr>
<tr><td><code>static inline bool cmc_str_str(FILE *file, char *element);</code></td></tr>
</tbody></table>
<br>
<br>
<table><thead><tr><th>free</th></tr></thead><tbody>
</tbody></table>
<br>
<br>
<table><thead><tr><th>hash</th></tr></thead><tbody>
<tr><td><code>static inline size_t cmc_i64_hash(int64_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_i32_hash(int32_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_i16_hash(int16_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_i8_hash(int8_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_u64_hash(uint64_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_u32_hash(uint32_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_u16_hash(uint16_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_u8_hash(uint8_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_size_hash(size_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_imax_hash(intmax_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_umax_hash(uintmax_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_float_hash(float e);</code></td></tr>
<tr><td><code>static inline size_t cmc_double_hash(double e);</code></td></tr>
<tr><td><code>static inline size_t cmc_str_hash_djb2(char *str);</code></td></tr>
<tr><td><code>static inline size_t cmc_str_hash_sdbm(char *str);</code></td></tr>
<tr><td><code>static inline size_t cmc_str_hash_java(char *str);</code></td></tr>
<tr><td><code>static inline size_t cmc_str_hash_murmur3(uint64_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_str_hash_murmur3_variant(uint64_t e);</code></td></tr>
<tr><td><code>static inline size_t cmc_i64_hash_mix(int64_t element);</code></td></tr>
<tr><td><code>static inline size_t cmc_u64_hash_mix(uint64_t element);</code></td></tr>
</tbody></table>
<br>
<br>
<table><thead><tr><th>pri</th></tr></thead><tbody>
</tbody></table>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/foreach.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/log.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/foreach.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/log.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+12 -3
View File
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html" class="active"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../utl/index.html" class="active"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -150,13 +150,22 @@
<main>
<h1><a class="header" href="#utl" id="utl">UTL</a></h1>
<p>Inside the <code>./utl/</code> folder there are many utility functions and macros that can be extensively used with the C Macro Collections library. Most of these utilities can be used without the main library.</p>
<h2><a class="header" href="#contents" id="contents">Contents</a></h2>
<ul>
<li><a href="assert.h/index.html">assert.h</a> - Non-abortive assert macros</li>
<li><a href="foreach.h/index.html">foreach.h</a> - For Each macros</li>
<li><a href="futils.h/index.html">futils.h</a> - Common functions used by Functions Table</li>
<li><a href="log.h/index.html">log.h</a> - Logging utility with levels of severity</li>
<li><a href="test.h/index.html">test.h</a> - Simple Unit Test building with macros</li>
<li><a href="timer.h/index.html">timer.h</a> - Timing code execution utility</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../Overview/overview.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../sac/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
@@ -174,7 +183,7 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../Overview/overview.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../sac/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
+280
View File
@@ -0,0 +1,280 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Configuration - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html" class="active"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#configuration" id="configuration">Configuration</a></h1>
<h2><a class="header" href="#cmc_log_config" id="cmc_log_config">cmc_log_config</a></h2>
<p>This is an anonymous static <code>struct</code> that can be directly modified to change logging levels, enable or disable output or change file output.</p>
<pre><code class="language-c">static struct
{
enum cmc_log_type tlevel;
enum cmc_log_type flevel;
bool tenabled;
bool fenabled;
bool enabled;
FILE * file;
} cmc_log_config = { 0, 0, true, true, true, NULL };
</code></pre>
<p><strong>Members</strong></p>
<ul>
<li><code>tlevel</code> - Terminal log level (<code>stderr</code>)</li>
<li><code>flevel</code> - File log level</li>
<li><code>tenabled</code> - Terminal logging enabled if <code>true</code></li>
<li><code>fenabled</code> - File logging enabled if <code>true</code></li>
<li><code>enabled</code> - Enables or disables all logs</li>
<li><code>FILE *file</code> - File for output</li>
</ul>
<p>This configuration is global to every log. The <code>FILE</code> pointer is not handled by the API and needs to be able to write to the file.</p>
<h2><a class="header" href="#log-level" id="log-level">Log Level</a></h2>
<p>By tuning <code>tlevel</code> and <code>flevel</code> (both accessed from <code>cmc_log_config</code>) you can filter which log messages are printed or not.</p>
<ul>
<li>If the log level is <code>0</code>, all logs are enabled</li>
<li>If the log level <code>X</code> is positive:
<ul>
<li>All levels less than <code>X</code> will be disabled</li>
<li>If <code>X</code> is greater than the level of <code>FATAL</code>, all logs are disabled</li>
</ul>
</li>
<li>If the log level <code>X</code> is negative:
<ul>
<li>All levels greater than <code>abs(X)</code> are enabled</li>
<li>If <code>abs(X)</code> is greater than the level of <code>FATAL</code>, all logs are enabled</li>
</ul>
</li>
</ul>
<p><strong>Examples</strong></p>
<p>If you want to output only <code>TRACE</code> logs to a file and the rest to <code>stderr</code>:</p>
<ul>
<li><code>cmc_log_config.tlevel = CMC_LOG_DEBUG</code></li>
<li><code>cmc_log_config.flevel = -CMC_LOG_TRACE</code></li>
</ul>
<p>If you want to output only <code>FATAL</code> to <code>stderr</code> and the rest to a file:</p>
<ul>
<li><code>cmc_log_config.tlevel = CMC_LOG_FATAL</code></li>
<li><code>cmc_log_config.flevel = -CMC_LOG_ERROR</code></li>
</ul>
<p>If you want to output only <code>FATAL</code> and <code>ERROR</code> to a file an nothing to <code>stderr</code>:</p>
<ul>
<li><code>cmc_log_config.tlevel = CMC_LOG_FATAL + 1</code></li>
<li><code>cmc_log_config.flevel = CMC_LOG_ERROR</code></li>
</ul>
<p><strong>Summary</strong></p>
<ul>
<li>Log Level &gt; 0: &quot;Allow all log levels that are greater than this, including it&quot;</li>
<li>Log Level &lt; 0: &quot;Allow all log levels that are smaller than this, including it&quot;</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/log.h/log_functions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/log.h/meanings.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/log.h/log_functions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/log.h/meanings.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Array Assertion - C Macro Collections</title>
<title>log.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -81,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../../utl/assert.h/array_assertion.html" class="active"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html" class="active"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -148,20 +148,35 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#array-assertion" id="array-assertion">Array Assertion</a></h1>
<h1><a class="header" href="#logh" id="logh">log.h</a></h1>
<p>Simple and customizable logging macros. Messages can have a custom logging level and a custom file output. This customization can be done via the global variable <a href="configuration.html#cmc_log_config"><code>cmc_log_config</code></a>. Logs are outputted to <code>stderr</code>.</p>
<h2><a class="header" href="#cmc_log_type" id="cmc_log_type">cmc_log_type</a></h2>
<p>Defines the possible Log Levels. These are used to categorize log messages. The higher the number, the more severe or important that message is. Check out <a href="meanings.html">here</a></p>
<pre><code class="language-c">enum cmc_log_type
{
CMC_LOG_TRACE = 1,
CMC_LOG_DEBUG = 2,
CMC_LOG_INFO = 3,
CMC_LOG_WARN = 4,
CMC_LOG_ERROR = 5,
CMC_LOG_FATAL = 6
};
</code></pre>
<h2><a class="header" href="#cmc_log_color" id="cmc_log_color">CMC_LOG_COLOR</a></h2>
<p>If this macro is defined, logging will be outputted with <a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors">ANSI color escape codes</a>. If you are logging into a file, these escape codes are not printed.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/assert.h/single_value_assertion.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="../../utl/futils.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/foreach.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="../../utl/log.h/log_functions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
@@ -173,13 +188,13 @@
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/assert.h/single_value_assertion.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a href="../../utl/futils.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/foreach.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a href="../../utl/log.h/log_functions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
+268
View File
@@ -0,0 +1,268 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Log Functions - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html" class="active"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#log-functions" id="log-functions">Log Functions</a></h1>
<h2><a class="header" href="#cmc_log_trace" id="cmc_log_trace">cmc_log_trace</a></h2>
<p>Defines a message with a Log Level of <code>CMC_LOG_TRACE</code>.</p>
<pre><code class="language-c">#define cmc_log_trace(fmt, ...)
</code></pre>
<ul>
<li><code>fmt</code> - A string that contains a text to be written that may contain format specifiers</li>
<li><code>...</code> - Optional. Values to be formatted into the string that will be printed</li>
</ul>
<h2><a class="header" href="#cmc_log_debug" id="cmc_log_debug">cmc_log_debug</a></h2>
<p>Defines a message with a Log Level of <code>CMC_LOG_DEBUG</code>.</p>
<pre><code class="language-c">#define cmc_log_debug(fmt, ...)
</code></pre>
<ul>
<li><code>fmt</code> - A string that contains a text to be written that may contain format specifiers</li>
<li><code>...</code> - Optional. Values to be formatted into the string that will be printed</li>
</ul>
<h2><a class="header" href="#cmc_log_info" id="cmc_log_info">cmc_log_info</a></h2>
<p>Defines a message with a Log Level of <code>CMC_LOG_INFO</code>.</p>
<pre><code class="language-c">#define cmc_log_info(fmt, ...)
</code></pre>
<ul>
<li><code>fmt</code> - A string that contains a text to be written that may contain format specifiers</li>
<li><code>...</code> - Optional. Values to be formatted into the string that will be printed</li>
</ul>
<h2><a class="header" href="#cmc_log_warn" id="cmc_log_warn">cmc_log_warn</a></h2>
<p>Defines a message with a Log Level of <code>CMC_LOG_WARN</code>.</p>
<pre><code class="language-c">#define cmc_log_warn(fmt, ...)
</code></pre>
<ul>
<li><code>fmt</code> - A string that contains a text to be written that may contain format specifiers</li>
<li><code>...</code> - Optional. Values to be formatted into the string that will be printed</li>
</ul>
<h2><a class="header" href="#cmc_log_error" id="cmc_log_error">cmc_log_error</a></h2>
<p>Defines a message with a Log Level of <code>CMC_LOG_ERROR</code>.</p>
<pre><code class="language-c">#define cmc_log_error(fmt, ...)
</code></pre>
<ul>
<li><code>fmt</code> - A string that contains a text to be written that may contain format specifiers</li>
<li><code>...</code> - Optional. Values to be formatted into the string that will be printed</li>
</ul>
<h2><a class="header" href="#cmc_log_fatal" id="cmc_log_fatal">cmc_log_fatal</a></h2>
<p>Defines a message with a Log Level of <code>CMC_LOG_FATAL</code>.</p>
<pre><code class="language-c">#define cmc_log_fatal(fmt, ...)
</code></pre>
<ul>
<li><code>fmt</code> - A string that contains a text to be written that may contain format specifiers</li>
<li><code>...</code> - Optional. Values to be formatted into the string that will be printed</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/log.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/log.h/configuration.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/log.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/log.h/configuration.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+229
View File
@@ -0,0 +1,229 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Meanings - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html" class="active"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#meanings" id="meanings">Meanings</a></h1>
<p>What does each Log Level means? It depends on the application. In here you will read more about how the C Macro Collections library uses each of these Log Levels, but this does not mean you should use them like described.</p>
<ul>
<li><strong>TRACE</strong> - Trace is used to describe the inner workings of a function or an algorithm. These messages can be used extensively, meaning that their content is probably not very useful, even for debugging.</li>
<li><strong>DEBUG</strong> - Mainly used for debugging, tracking certain variables, checking if pointers were deallocated or anything useful to help visualizing what your program is doing in general.</li>
<li><strong>INFO</strong> - Info can be used as a heads up. Something that is important to note, but is not quite a warning or an error.</li>
<li><strong>WARN</strong> - Warnings are attributed to all cases where the function can recover from and usually treated by it. In most cases the user can treat these warnings himself.</li>
<li><strong>ERROR</strong> - Something really bad happened. Your program will not crash yet but depending on what comes next, it will. This might be attributed to pointers that shouldn't be null because later functions might use it.</li>
<li><strong>FATAL</strong> - This will probably be the last logging message before your program crashes or goes into madness. Fatal errors are commonly attributed to dereferencing NULL pointers.</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/log.h/configuration.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/test.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/log.h/configuration.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/test.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
-221
View File
@@ -1,221 +0,0 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>log.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html" class="active"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#logh" id="logh">log.h</a></h1>
<p>Logging utility.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../utl/foreach.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../utl/test.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../utl/foreach.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../utl/test.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+315
View File
@@ -0,0 +1,315 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>test.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html" class="active"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#testh" id="testh">test.h</a></h1>
<p>A simple <a href="https://en.wikipedia.org/wiki/Unit_testing">Unit Test</a> utility used by the C Macro Collections Library. It has two main components: a Unit and a Test.</p>
<p>This utility uses two other libraries defined in the C Macro Collections library:</p>
<ul>
<li><a href="../assert.h/index.html"><code>assert.h</code></a></li>
<li><a href="../timer.h/index.html"><code>timer.h</code></a></li>
</ul>
<p>When a test is created inside a unit, it will first set the global variable <a href="../assert.h/index.html#cmc_assert_state"><code>cmc_assert_state</code></a> to <code>true</code>. Then, inside the test you can use the assertions provided by the <code>assert.h</code> library to pass or fail a unit test automatically. By the end of a test the variable will be checked. If <code>false</code> it means that a certain assertion failed.</p>
<p>The runtime of each Unit Test is calculated using the <code>timer.h</code> library.</p>
<h2><a class="header" href="#cmc_create_unit" id="cmc_create_unit">CMC_CREATE_UNIT</a></h2>
<p>Creates a Unit that can contain tests.</p>
<pre><code class="language-c">#define CMC_CREATE_UNIT(UNAME, VERBOSE, BODY)
</code></pre>
<ul>
<li><code>UNAME</code> - Unit name. This needs to be a valid function name!</li>
<li><code>VERBOSE</code> - Either <code>true</code> or <code>false</code>. If <code>true</code>, prints every message of <code>PASSED</code> or <code>FAILED</code> from each test</li>
<li><code>BODY</code> - A block of code containing tests</li>
</ul>
<h2><a class="header" href="#cmc_create_test" id="cmc_create_test">CMC_CREATE_TEST</a></h2>
<p>Creates a test within a unit. This macro can only be used inside the <code>BODY</code> of a <code>CMC_CREATE_UNIT</code> since it uses local variables allocated by the latter.</p>
<pre><code class="language-c">#define CMC_CREATE_TEST(TNAME, BODY)
</code></pre>
<ul>
<li><code>TNAME</code> - Test name</li>
<li><code>BODY</code> - A block of code containing the test itself</li>
</ul>
<p>Inside a test you can use the assertions from <code>assert.h</code> to automatically pass or fail a test.</p>
<h2><a class="header" href="#cmc_test_abort" id="cmc_test_abort">CMC_TEST_ABORT</a></h2>
<p>Aborts a unit test. This will jump to a <code>goto</code> located at the end of the Unit Test. Must be called inside a <code>CMC_CREATE_TEST</code>.</p>
<pre><code class="language-c">#define CMC_TEST_ABORT()
</code></pre>
<h2><a class="header" href="#cmc_test_info" id="cmc_test_info">cmc_test_info</a></h2>
<p>Contains information about a Unit Test. Used internally.</p>
<pre><code class="language-c">struct cmc_test_info
{
uintmax_t total;
uintmax_t passed;
uintmax_t failed;
uintmax_t assert_total;
uintmax_t assert_failed;
bool aborted;
bool verbose;
};
</code></pre>
<ul>
<li><code>uintmax_t total</code> - Total tests in the unit test</li>
<li><code>uintmax_t passed</code> - Total tests passed in the unit test</li>
<li><code>uintmax_t failed</code> - Total tests failed in the unit test</li>
<li><code>uintmax_t assert_total</code> - Total assertions in the unit test</li>
<li><code>uintmax_t assert_failed</code> - Total assertions failed in the unit test</li>
<li><code>bool aborted</code> - If the unit test was aborted</li>
<li><code>bool verbose</code> - Information about each test is displayed</li>
</ul>
<h2><a class="header" href="#cmc_test_color" id="cmc_test_color">CMC_TEST_COLOR</a></h2>
<p>Define this macro if you wish to have color output from the messages printed by each test. Note that a Unit Test need to have <code>VERBOSE</code> equal to <code>true</code>.</p>
<h2><a class="header" href="#example" id="example">Example</a></h2>
<pre><code class="language-c">#include &quot;utl/test.h&quot;
CMC_CREATE_UNIT(check_math, true, {
CMC_CREATE_TEST(summation, {
// assert.h already comes with test.h
cmc_assert_equals(int32_t, 4, 2 + 2);
});
CMC_CREATE_TEST(subtraction, {
cmc_assert_equals(int32_t, -1, 2 - 3);
});
CMC_CREATE_TEST(this will fail, {
// test names can be text as long as they don't have a comma
cmc_assert_greater(double, 1.0, 0.0);
});
CMC_CREATE_TEST(fish, {
// You can also manually fail a test
if (strcmp(&quot;2 + 2&quot;, &quot;fish&quot;) != 0)
cmc_assert_state = false;
});
CMC_CREATE_TEST(abort!, {
if (4 % 2 == 0)
CMC_TEST_ABORT();
});
CMC_CREATE_TEST(sad..., {
// This test won't be called because unit test was aborted above
cmc_assert(true);
});
});
int main(void)
{
// returns how many tests failed
return check_math();
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/log.h/meanings.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../utl/timer.h/index.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/log.h/meanings.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../utl/timer.h/index.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
+269
View File
@@ -0,0 +1,269 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>timer.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../../favicon.png">
<link rel="stylesheet" href="../../css/variables.css">
<link rel="stylesheet" href="../../css/general.css">
<link rel="stylesheet" href="../../css/chrome.css">
<link rel="stylesheet" href="../../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../../highlight.css">
<link rel="stylesheet" href="../../tomorrow-night.css">
<link rel="stylesheet" href="../../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../../Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="../../Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="../../Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="../../Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="../../cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="../../cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="../../cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../../cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="../../cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="../../cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="../../cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="../../cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="../../cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="../../dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="../../sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="../../utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="../../utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="../../utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="../../utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="../../utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="../../utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="../../utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="../../utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="../../utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="../../utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="../../utl/timer.h/index.html" class="active"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../../Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#timerh" id="timerh">timer.h</a></h1>
<p>A very simple library that encapsulates <code>clock()</code> from <code>&lt;time.h&gt;</code>, making life easier.</p>
<h2><a class="header" href="#cmc_timer" id="cmc_timer">cmc_timer</a></h2>
<pre><code class="language-c">struct cmc_timer
{
clock_t start;
clock_t stop;
double result;
};
</code></pre>
<ul>
<li><code>clock_t start</code> - Start of timing</li>
<li><code>clock_t stop</code> - End of timing</li>
<li><code>double result</code> - Result in milliseconds</li>
</ul>
<h2><a class="header" href="#cmc_timer_start" id="cmc_timer_start">cmc_timer_start</a></h2>
<p>Starts the timer by setting <code>start</code> with <code>clock()</code>.</p>
<pre><code class="language-c">#define cmc_timer_start(timer)
</code></pre>
<ul>
<li><code>timer</code> - A <code>struct cmc_timer</code> variable</li>
</ul>
<h2><a class="header" href="#cmc_timer_stop" id="cmc_timer_stop">cmc_timer_stop</a></h2>
<p>Sets the <code>stop</code> variable with <code>clock()</code> and calculates the <code>result</code> in milliseconds.</p>
<pre><code class="language-c">#define cmc_timer_start(timer)
</code></pre>
<ul>
<li><code>timer</code> - A <code>struct cmc_timer</code> variable</li>
</ul>
<h2><a class="header" href="#example" id="example">Example</a></h2>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &quot;utl/timer.h&quot;
int main(void)
{
struct cmc_timer t;
cmc_timer_start(t);
size_t total = 0;
for (size_t i = 0; i &lt; 1000000000; i++)
total += i;
cmc_timer_stop(t);
printf(&quot;Sum took %.0lf milliseconds to calculate\n&quot;, t.result);
}
</code></pre>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../../utl/test.h/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../../Examples/examples.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../../utl/test.h/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../Examples/examples.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
-221
View File
@@ -1,221 +0,0 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>timer.h - C Macro Collections</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" />
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
<ol class="chapter"><li class="expanded "><a href="../Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="../Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="../Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="../Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="../Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="../Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="../Features/features.html"><strong aria-hidden="true">2.</strong> Features</a></li><li><ol class="section"><li class="expanded "><a href="../Features/two_way_iterators.html"><strong aria-hidden="true">2.1.</strong> Two way iterators</a></li><li class="expanded "><a href="../Features/custom_allocation.html"><strong aria-hidden="true">2.2.</strong> Custom allocation</a></li><li class="expanded "><a href="../Features/callbacks.html"><strong aria-hidden="true">2.3.</strong> Callbacks</a></li><li class="expanded "><a href="../Features/functions_table.html"><strong aria-hidden="true">2.4.</strong> Functions Table</a></li></ol></li><li class="expanded "><a href="../Overview/overview.html"><strong aria-hidden="true">3.</strong> Collections Overview</a></li><li class="expanded "><a href="../utl/utl.html"><strong aria-hidden="true">4.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/index.html"><strong aria-hidden="true">4.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="../utl/assert.h/overview.html"><strong aria-hidden="true">4.1.1.</strong> Overview</a></li><li class="expanded "><a href="../utl/assert.h/single_value_assertion.html"><strong aria-hidden="true">4.1.2.</strong> Single Value Assertion</a></li><li class="expanded "><a href="../utl/assert.h/array_assertion.html"><strong aria-hidden="true">4.1.3.</strong> Array Assertion</a></li></ol></li><li class="expanded "><a href="../utl/foreach.html"><strong aria-hidden="true">4.2.</strong> foreach.h</a></li><li class="expanded "><a href="../utl/log.html"><strong aria-hidden="true">4.3.</strong> log.h</a></li><li class="expanded "><a href="../utl/test.html"><strong aria-hidden="true">4.4.</strong> test.h</a></li><li class="expanded "><a href="../utl/timer.html" class="active"><strong aria-hidden="true">4.5.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="../Examples/examples.html"><strong aria-hidden="true">5.</strong> Examples</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar" class="menu-bar">
<div id="menu-bar-sticky-container">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</button>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">C Macro Collections</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1><a class="header" href="#timerh" id="timerh">timer.h</a></h1>
<p>Simple code execution utility.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../utl/test.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next" href="../Examples/examples.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a href="../utl/test.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a href="../Examples/examples.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script type="text/javascript">
window.playpen_copyable = true;
</script>
<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="../book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts -->
</body>
</html>
-13
View File
@@ -1,13 +0,0 @@
# Callbacks
Every collection can have an optional callback node. In this node there are five functions:
| | |
|-|-|
| `create` | Is called when an element was successfully added to the collection |
| `read` | Is called when the collection was successfully queried about an element |
| `update` | Is called when an element in the collection was successfully updated |
| `delete` | Is called when an element was successfully removed from the collection |
| `resize` | Is called when the collection was full and successfully resized |
Check the documentation for each collection to see which functions call which callbacks.
@@ -1,8 +0,0 @@
# Custom Allocation
All collections have an allocation node. This node can be modified so that every allocation and de-allocation can be done with custom functions. The allocation node has pointers to functions that correspond to:
* `calloc`
* `free`
* `malloc`
* `realloc`
-3
View File
@@ -1,3 +0,0 @@
# Features
The C Macro Collections Library comes with powerful collections. In this section you will better understand many features that are common to all data structures.
@@ -1,3 +1,5 @@
# How to Use the Library
The C Macro Collections Library comes with very powerful data structures and they are only one macro away from you.
TODO
@@ -6,10 +6,17 @@
<p align="center">Header only, macro generated, generic and type-safe Collections in C.</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections"><img src="https://img.shields.io/badge/GitHub-C%20Macro%20Collections-2195F3.svg?logo=github" alt="LinkToRepo"/></a>
<a href="https://leoven.github.io/C-Macro-Collections/"><img style="color: #ffffff;" src="https://img.shields.io/badge/Read%20the%20Docs-D13636.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHN0eWxlPSIiPjxyZWN0IGlkPSJiYWNrZ3JvdW5kcmVjdCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgeD0iMCIgeT0iMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJub25lIi8%2BPHRpdGxlPmljbi9kb2MtdGV4dDwvdGl0bGU%2BPGcgY2xhc3M9ImN1cnJlbnRMYXllciIgc3R5bGU9IiI%2BPHRpdGxlPkxheWVyIDE8L3RpdGxlPjxwYXRoIGQ9Ik01IDFoNC4yNDRhMiAyIDAgMCAxIDEuNDM0LjYwNmwyLjc1NiAyLjgzNEEyIDIgMCAwIDEgMTQgNS44MzVWMTJhMyAzIDAgMCAxLTMgM0g1YTMgMyAwIDAgMS0zLTNWNGEzIDMgMCAwIDEgMy0zem0wIDJhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjUuODM1TDkuMjQ0IDNINXptMS41IDdoM2EuNS41IDAgMSAxIDAgMWgtM2EuNS41IDAgMSAxIDAtMXptMC0yaDJhLjUuNSAwIDAgMSAwIDFoLTJhLjUuNSAwIDAgMSAwLTF6TTggMmwzIDEuOTk1TDEzIDdIOWExIDEgMCAwIDEtMS0xVjJ6IiBpZD0iYSIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8%2BPC9nPjwvc3ZnPg%3D%3D" alt="LinkToDocs"/></a>
</p>
<p align="center">
<a href="https://github.com/LeoVen/C-Macro-Collections/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"/></a>
<img src="https://img.shields.io/badge/Version-v0.23.1-orange.svg" alt="Version"/>
<a href="https://travis-ci.org/LeoVen/C-Macro-Collections"><img src="https://travis-ci.org/LeoVen/C-Macro-Collections.svg?branch=master" alt="travis-ci"/></a>
<a href="https://codecov.io/gh/LeoVen/C-Macro-Collections"><img src="https://codecov.io/gh/LeoVen/C-Macro-Collections/branch/master/graph/badge.svg" alt="codecov"/></a>
<img src="https://github.com/LeoVen/C-Macro-Collections/workflows/Test%20Suit/badge.svg?branch=master" alt="test_suit"/>
</p>
The C Macro Collections Library is a compilation of macros that can be used to generate common data structures for any desired type. These data structures are [type safe](https://en.wikipedia.org/wiki/Type_safety) and are powered with many features (see Features section).
@@ -15,4 +15,4 @@ All with the following features:
* __Nesting__ - Collections can be nested (List of Lists, HashSet of Stacks, etc);
* __One macro to rule them all__ - Only one macro to generate everything and that's it.
and many other powerful features (see [Features](../Features/features.html)).
and many other powerful features (see [Features](../Overview/features_overview.html)).
@@ -0,0 +1,11 @@
# Features Overview
The C Macro Collections library comes with some core features available to all collections.
| Feature | Description |
| ------- | ----------- |
| [Callbacks](../cor/callbacks/index.html) | Callbacks are functions that are called when an operation is successful. These operations are divided in 5 categories (create, read, update, delete, resize). |
| [Custom Allocation](../cor/custom_allocation/index.html) | Allows you to use your own custom dynamic memory allocation functions inside the collections. |
| [Error Codes](../cor/error_codes/index.md) | Error codes that can be used to treat certain common errors when operating on a collection. |
| [Functions Table](../cor/functions_table/index.html) | A standard way to access required behaviors from the custom data types. Things like hash, comparison, freeing from memory if needed, etc. |
| [Iterators](../cor/iterators/index.html) | Iterators are a simplified access to the values of a collection. |
+32
View File
@@ -0,0 +1,32 @@
# Files Overview
An overview of the source files (all `.h`) of the C Macro Collections library.
* `./cmc` - The main C Macro Collections library
* `./bidimap.h` - A bi-directional map based on a hash table
* `./deque.h` - A double-ended queue
* `./hashmap.h` - A map based on a hash table
* `./hashset.h` - A set based on a hash table
* `./heap.h` - A binary heap based on a dynamic array
* `./intervalheap.h` - A heap that is both Min and Max based on a dynamic array
* `./linkedlist.h` - A doubly-linked list
* `./list.h` - A dynamic array
* `./multimap.h` - A map that accepts multiple keys based on a hash table
* `./multiset.h` - A multiset based on a hash table
* `./queue.h` - A FIFO based on a circular dynamic array
* `./sortedlist.h` - A sorted list based on a dynamic array
* `./stack.h` - A LIFO based on a dynamic array
* `./treemap.h` - A sorted map based on an AVL tree
* `./treeset.h` - A sorted set based on an AVL tree
* `./cor` - Core functionalities of the C Macro Collections libraries
* `./core.h` - Core functionalities of the library
* `./hashtable.h` - Common things used by hash table based collections
* `./dev` - A mirror of the main library to be used during development
* `./sac` - Statically Allocated Collections that don't use dynamic allocation
* `./utl` - Utilities
* `./assert.h` - Non-abortive assert macros
* `./foreach.h` - For Each macros
* `./futils.h` - Common functions used by Functions Table
* `./log.h` - Logging utility with levels of severity
* `./test.h` - Simple Unit Test building with macros
* `./test.h` - Timing code execution utility
+3
View File
@@ -0,0 +1,3 @@
# Overview
In this section you will be able to quickly glance at what are the core functionalities that the C Macro Collections library can bring you.
+27 -13
View File
@@ -6,19 +6,33 @@
- [Library structure](./Introduction/library_structure.md)
- [Understanding the library](./Introduction/understanding_the_library.md)
- [How to use the library](./Introduction/how_to_use_the_library.md)
- [Features](./Features/features.md)
- [Two way iterators](./Features/two_way_iterators.md)
- [Custom allocation](./Features/custom_allocation.md)
- [Callbacks](./Features/callbacks.md)
- [Functions Table](./Features/functions_table.md)
- [Collections Overview](./Overview/overview.md)
- [utl](./utl/utl.md)
- [Overview](./Overview/index.md)
- [Collections Overview](./Overview/collections_overview.md)
- [Features Overview](./Overview/features_overview.md)
- [Files Overview](./Overview/files_overview.md)
- [cor](./cor/index.md)
- [Callbacks](./cor/callbacks/index.md)
- [Custom allocation](./cor/custom_allocation/index.md)
- [Error Codes](./cor/error_codes/index.md)
- [Functions Table](./cor/functions_table/index.md)
- [Iterators](./cor/iterators/index.md)
- [cmc](./cmc/index.md)
- [bitset.h](./cmc/bitset.h/index.md)
- [deque.h](./cmc/deque.h/index.md)
- [Functions.h](./cmc/deque.h/functions.md)
- [dev](./dev/index.md)
- [sac](./sac/index.md)
- [utl](./utl/index.md)
- [assert.h](./utl/assert.h/index.md)
- [Overview](./utl/assert.h/overview.md)
- [Single Value Assertion](./utl/assert.h/single_value_assertion.md)
- [Array Assertion](./utl/assert.h/array_assertion.md)
- [foreach.h](./utl/foreach.md)
- [log.h](./utl/log.md)
- [test.h](./utl/test.md)
- [timer.h](./utl/timer.md)
- [Valued Assertions](./utl/assert.h/valued_assertions.md)
- [Generic Assertions](./utl/assert.h/generic_assertions.md)
- [foreach.h](./utl/foreach.h/index.md)
- [futils.h](./utl/futils.h/index.md)
- [log.h](./utl/log.h/index.md)
- [Log Functions](./utl/log.h/log_functions.md)
- [Configuration](./utl/log.h/configuration.md)
- [Meanings](./utl/log.h/meanings.md)
- [test.h](./utl/test.h/index.md)
- [timer.h](./utl/timer.h/index.md)
- [Examples](./Examples/examples.md)
+77
View File
@@ -0,0 +1,77 @@
# bitset.h
A Bit Set is an array where each bit can be individually modified and queried by using bitwise operators such as `|`, `&`, `^`, `~`, `>>` and `<<` (`or`, `and`, `xor`, `not`, `right shift`, `left shift` respectively).
## BitSet Implementation
This BitSet implementation uses an array of type `cmc_bitset_word` which can be `typedef`ed to any unsigned type such as `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`, `size_t`, etc. The BitSet does not make use of `K` or `V`. Because of that, it also doesn't have Functions Tables.
The BitSet is initialized with a custom capacity but, if a bit index accessed is greater than the total capacity, the BitSet will resize. This means that the BitSet will try to guarantee that every bit index is accessible, as long as there is enough memory.
## BitSet Generation Macros
* `CMC_GENERATE_BITSET(PFX, SNAME)` - Generate full definition.
* `CMC_GENERATE_BITSET_HEADER(PFX, SNAME)` - Generate only the header portion
* `CMC_GENERATE_BITSET_SOURCE(PFX, SNAME)` - Generate only the source portion
| Parameter | Description |
| --------- | ----------------------------- |
| `PFX` | Functions namespace or prefix |
| `SNAME` | Structure name |
## BitSet Structures
| Declared structs | Description |
| ------------------------- | ----------------------------------- |
| `struct SNAME` | A bit set data structure |
| `struct SNAME##_iter` | A bit set iterator |
## struct SNAME
| `struct SNAME` | Description |
| --------------------------------- | ------------------------------------------ |
| `cmc_bitset_word *buffer` | Dynamic array of bits. |
| `size_t capacity` | Current array capacity . |
| `int flag` | Flag indicating errors or success. |
| `struct cmc_alloc_node *alloc` | Custom allocation functions. |
| `struct cmc_callbacks *callbacks` | Callback functions. |
## struct SNAME##_iter
| `struct SNAME##_iter` | Description |
| ---------------------- | --------------------------------------------------- |
| `struct SNAME *target` | BitSet being iterated over. |
| `size_t cursor` | Cursor's current position (index). |
| `bool start` | If the iterator reached the start of the iteration. |
| `bool end` | If the iterator reached the end of iteration. |
## cmc_bitset_word
The `typedef`ed data type o the underlying bit set buffer.
```c
typedef uint32_t cmc_bitset_word;
```
This `typedef` can be changed to any unsigned integer data type and the bit set will still work properly.
## Callbacks
This list associates which functions calls which callbacks.
* `create`
* `PFX##_set()`
* `PFX##_set_range()`
* `read`
* `update`
* `delete`
* `PFX##_clear()`
* `PFX##_clear_range()`
* `resize`
* `PFX##_resize()`
## Functions Table
| CMP | CPY | STR | FREE | HASH | PRI |
| :-: | :-: | :-: | :--: | :--: | :-: |
| ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
+79
View File
@@ -0,0 +1,79 @@
# Index
__Deque__
* [`_new()`](#_new)
* [`_new_custom()`](#_new_custom)
* `_clear()`
* `_free()`
* `_customize()`
* `_push_front()`
* `_push_back()`
* `_pop_front()`
* `_front()`
* `_back()`
* `_contains()`
* `_empty()`
* `_full()`
* `_count()`
* `_capacity()`
* `_flag()`
* `_resize()`
* `_copy_of()`
* `_equals()`
* `_to_string()`
* `_print()`
__Deque Iterator__
WIP.
## [<span id="_new"> \_new() </span>](#index)
Allocates on the heap and returns a new Deque with an internal capacity of the specified value. The Deque will be empty, using the default allocator `cmc_alloc_node_default` and no callbacks will be set, that is, `callbacks` will be set to `NULL`. Its `flag` will be initially `cmc_flags.OK`.
__Declaration__
`struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val);`
__Parameters__
| Parameter | Required | Description |
| ---------------------------- | -------- | ------------------------------------ |
| `size_t capacity` | Yes | The initial Deque capacity |
| `struct SNAME##_fval *f_val` | Yes | A Functions Table for `V` |
__Returns__
| Returns | When |
| ---------------- | ---------------------------------------------------------------- |
| `struct SNAME *` | If operation was successful |
| `NULL` | If allocation failed, if capacity is `0` or if `f_val` is `NULL` |
## [<span id="_new_custom"> \_new\_custom() </span>](#index)
Like [\_new()](#_new) but allows for custom allocation node and callbacks. The allocation node is optional. If present, the function will immediately use it to allocate the new Deque. If `NULL`, `cmc_alloc_node_default` will instead be used.
__Declaration__
```
struct SNAME *PFX##_new_custom(size_t capacity, struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
```
__Parameters__
| Parameter | Required | Description |
| --------------------------------- | -------- | ------------------------------------ |
| `size_t capacity` | Yes | The initial Deque capacity |
| `struct SNAME##_fval *f_val` | Yes | A Functions Table for `V` |
| `struct cmc_alloc_node *alloc` | No | A custom allocation node |
| `struct cmc_callbacks *callbacks` | No | A custom callbacks struct |
__Returns__
| Returns | When |
| ---------------- | ---------------------------------------------------------------- |
| `struct SNAME *` | If operation was successful |
| `NULL` | If allocation failed, if capacity is `0` or if `f_val` is `NULL` |
+81
View File
@@ -0,0 +1,81 @@
# deque.h
A Deque, also known as a double-ended queue, is a linear data structure that is able to add and remove elements from both ends. It can also be thought of a double-ended stack since you can push and pop elements from two ends. The Deque can also be used as a Queue. The only elements accessible from a Deque ar the two elements at its ends (front element and back element).
## Deque Implementation
This implementation uses a circular buffer (ring buffer or cyclic buffer) in order to operate on O(1) for push and pop on either ends. The only case where it takes longer than O(1) is when the buffer is reallocated. If it was implemented as a regular array, adding or removing elements from the front would take O(N) due to the need to shift all elements in the Deque.
Two indices are kept track of. The `front` index and the `rear` index. These represent the both ends of the Deque. If an index reaches one end of the real buffer, they wrap around to the other end and an element is added there. This abstracts the real buffer as a circular buffer with the cost os constantly checking for boundaries and using the modulo operator.
## Deque Generation Macros
* `CMC_GENERATE_DEQUE(PFX, SNAME, V)` - Generate full definition.
* `CMC_GENERATE_DEQUE_HEADER(PFX, SNAME, V)` - Generate only the header portion
* `CMC_GENERATE_DEQUE_SOURCE(PFX, SNAME, V)` - Generate only the source portion
| Parameter | Description |
| --------- | ----------------------------- |
| `PFX` | Functions namespace or prefix |
| `SNAME` | Structure name |
| `V` | Value type |
## Deque Structures
| Declared structs | Description |
| ------------------------- | ----------------------------------- |
| `struct SNAME` | A double-ended queue data structure |
| `struct SNAME##_fval` | A function table for the `V` type |
| `struct SNAME##_iter` | A double-ended queue iterator |
## struct SNAME
| `struct SNAME` | Description |
| --------------------------------- | ------------------------------------------ |
| `V *buffer` | Dynamic circular array of elements. |
| `size_t capacity` | Current circular array capacity. |
| `size_t count` | Current amount of elements. |
| `size_t front` | Index representing the front of the Deque. |
| `size_t rear` | Index representing the back of the Deque. |
| `int flag` | Flag indicating errors or success. |
| `struct SNAME##_fval *f_val` | Functions table for the Value type. |
| `struct cmc_alloc_node *alloc` | Custom allocation functions. |
| `struct cmc_callbacks *callbacks` | Callback functions. |
## struct SNAME##_fval
The Functions Table for `V`. Check out the Functions Table documentation [here](../../cor/functions_table/index.html).
## struct SNAME##_iter
| `struct SNAME##_iter` | Description |
| ---------------------- | --------------------------------------------------- |
| `struct SNAME *target` | Deque being iterated over. |
| `size_t cursor` | Cursor's current position (index). |
| `size_t index` | Relative index to all elements in the iteration. |
| `bool start` | If the iterator reached the start of the iteration. |
| `bool end` | If the iterator reached the end of iteration. |
## Callbacks
This list associates which functions calls which callbacks.
* `create`
* `PFX##_push_front()`
* `PFX##_push_back()`
* `read`
* `PFX##_front()`
* `PFX##_back()`
* `PFX##_contains()`
* `update`
* `delete`
* `PFX##_pop_front()`
* `PFX##_pop_back()`
* `resize`
* `PFX##_resize()`
## Functions Table
| CMP | CPY | STR | FREE | HASH | PRI |
| :-: | :-: | :-: | :--: | :--: | :-: |
| ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#9f3b94](https://placehold.it/20/9f3b94/000000?text=+) | ![#497edd](https://placehold.it/20/497edd/000000?text=+) | ![#00d3eb](https://placehold.it/20/00d3eb/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) | ![#2ef625](https://placehold.it/20/2ef625/000000?text=+) |
+27
View File
@@ -0,0 +1,27 @@
# CMC
The main C Macro Collections.
The C Macro Collections library was created out of necessity. To create powerful data structures of any type without the constant use of macros and `void *` pointers, but at the same time being [type-safe](https://en.wikipedia.org/wiki/Type_safety). These collections are generated by macros containing a template. These templates allow for some much needed customizations including the data type you wish to handle.
In the `cmc` folder is the default implementation of all collections. There is also a `dev` folder that pretty much has the same macros that expand to the same code, except that they have an extensive use of logging that might be useful for debugging or getting to know what is happening in your program. There is also the `sac` collections that are statically allocated (have a fixed sized buffer).
## Quick Example
Let's say you need a HashMap mapping keys of type `char *` to `int`. All you need to do is:
```c
#include "cmc/hashmap"
// CMC_GENERATE_HASHMAP(PFX, SNAME, K, V)
CMC_GENERATE_HASHMAP(map, hashmap, char *, int)
int main(void)
{
// Here you have full functionalities of a HashMap
// No more macros needed!
// Every function can be found in the 'map_' prefix and are all type-safe
}
```
You can customize the functions prefix (`PFX`) and the `struct` name (`SNAME`). The macro `CMC_GENERATE_HASHMAP` will expand to all the code that you will need to operate on a HashMap with `char *` keys and `int` values. The only thing left to do is to define a hash function and a comparator functions for the keys of this map. In case of `char *` you can find these functions in `utl/futils.h` or make your own. To know which collections require which functions check out [Functions Table](../cor/functions_table/index.html) or the documentation for each collection.
+60
View File
@@ -0,0 +1,60 @@
# Callbacks
Every collection can have an optional callback node. In this node there are five functions:
| Callback | Description |
| -------- | ----------------------------------------------------------------------- |
| `create` | Is called when an element was successfully added to the collection |
| `read` | Is called when the collection was successfully queried about an element |
| `update` | Is called when an element in the collection was successfully updated |
| `delete` | Is called when an element was successfully removed from the collection |
| `resize` | Is called when the collection was full and successfully resized |
Check the documentation for each collection to see which functions call which callbacks.
## cmc_callbacks
Every collection has a pointer to this `struct`. If it is `NULL` then the collection has no callbacks. Also, individual callbacks can be optional if set to `NULL`.
```c
struct cmc_callbacks
{
void (*create)(void);
void (*read)(void);
void (*update)(void);
void (*delete)(void);
void (*resize)(void);
};
```
## Example
```c
#include "cmc/heap.h"
#include "utl/futils.h" // cmc_i32_cmp
// Generate a heap of integers
CMC_GENERATE_HEAP(i32h, i32heap, int)
void heap_on_create(void)
{
printf("An element was added to the heap\n");
}
int main(void)
{
// create() is set but the other callbacks are not
struct cmc_callbacks my_callbacks = { .create = heap_on_create, NULL };
// Create a max heap with the callbacks
struct i32heap *heap = i32h_new_custom(
100, cmc_max_heap, &(struct i32heap_fval){ .cmp = cmc_i32_cmp }, NULL,
&my_callbacks);
i32h_insert(heap, 10);
i32h_insert(heap, 11);
i32h_insert(heap, 12);
i32h_free(heap);
}
```
@@ -0,0 +1,91 @@
# Custom Allocation
All collections have an allocation node. This node can be modified so that every allocation and de-allocation can be done with custom functions. Every custom allocation function must follow the same prototype of the `stdlib.h` functions.
## cmc_alloc_node
```c
struct cmc_alloc_node
{
void *(*malloc)(size_t);
void *(*calloc)(size_t, size_t);
void *(*realloc)(void *, size_t);
void (*free)(void *);
};
```
## cmc_alloc_node_default
The default allocation node. If a collections is not initialized with a custom allocation node, this will be the default one using the functions from the C standard library.
```c
static struct cmc_alloc_node cmc_alloc_node_default = { malloc, calloc,
realloc, free };
```
## Example
```c
#include "cmc/heap.h"
#include "utl/futils.h" // cmc_i32_cmp
// Total bytes allocated
size_t total = 0;
void *my_malloc(size_t size)
{
void *result = malloc(size);
if (!result)
return result;
total += size;
return result;
}
void *my_calloc(size_t count, size_t size)
{
void *result = calloc(count, size);
if (!result)
return result;
total += count * size;
return result;
}
void *my_realloc(void *block, size_t size)
{
void *result = realloc(block, size);
if (!result)
return result;
total += size;
return result;
}
// Generate a heap of integers
CMC_GENERATE_HEAP(i32h, i32heap, int)
int main(void)
{
// My custom allocation node
struct cmc_alloc_node node = { .malloc = my_malloc,
.calloc = my_calloc,
.realloc = my_realloc,
.free = free };
// Create a max heap with the custom allocation node
struct i32heap *heap = i32h_new_custom(
100, cmc_max_heap, &(struct i32heap_fval){ .cmp = cmc_i32_cmp }, &node,
NULL);
for (int i = 0; i < 100000; i++)
i32h_insert(heap, i);
i32h_free(heap);
printf("Total bytes allocated : %" PRIuMAX "\n", total);
}
```
+76
View File
@@ -0,0 +1,76 @@
# Error Codes
Error codes are ways to signal errors or success. It is accessed through the `flag` component of a `struct` or through a function that is present in every collection:
```c
int PFX##_flag(struct SNAME *_collection_);
```
Some functions have a return type of `bool` indicating if it exited successfully or not. These error codes can be used for further error handling.
## cmc_flags
It is a global `struct` with default values for error codes.
```c
static struct
{
int OK;
int ALLOC;
int EMPTY;
int NOT_FOUND;
int INVALID;
int RANGE;
int DUPLICATE;
int ERROR;
} cmc_flags = { 0, 1, 2, 3, 4, 5, 6, 7 };
```
* `OK` - No errors. The operation exited successfully.
* `ALLOC` - Allocation failed.
* `EMPTY` - The collection is empty when it shouldn't.
* `NOT_FOUND` - Key or value not found.
* `INVALID` - Invalid argument or operation given the collection's state
* `RANGE` - Index out of range.
* `DUPLICATE` - Duplicate key or value.
* `ERROR` - Generic error. Usually caused by algorithm errors.
## cmc_flags_to_str
Maps the integer representation of error codes to their character representation.
```c
const char *cmc_flags_to_str[8] = { "OK", "ALLOC", "EMPTY",
"NOT_FOUND", "INVALID", "RANGE",
"DUPLICATE", "ERROR" };
```
## Example
```c
#include "cmc/treeset.h"
#include "utl/futils.h" // cmc_i32_cmp
// Generate a sorted set of integers
CMC_GENERATE_TREESET(tset, sortedset, int)
int main(void)
{
struct sortedset *set =
tset_new(&(struct sortedset_fval){ .cmp = cmc_i32_cmp });
if (!tset_insert(set, 10))
printf("Error! %s\n", cmc_flags_to_str[tset_flag(set)]);
if (!tset_insert(set, 10))
printf("Error! %s\n", cmc_flags_to_str[tset_flag(set)]);
if (!tset_remove(set, 10))
printf("Error! %s\n", cmc_flags_to_str[tset_flag(set)]);
if (!tset_remove(set, 10))
printf("Error! %s\n", cmc_flags_to_str[tset_flag(set)]);
tset_free(set);
}
```
@@ -1,39 +1,101 @@
# Functions Table
Functions table are like a methods table for you custom data type. It is a `struct` of function pointers that you will need to define in order to some collections to work. Some functions are optional and others are needed in order to a collection to operate.
Functions Table is a `struct` with function pointers that are used to extract behavior from a custom data type. This exists because an `int` or a `char *` or `struct my_data_type` don't have default hash functions or ways to compare between them. This could be achieved with [operator overloading](https://en.wikipedia.org/wiki/Operator_overloading) but C doesn't have that. Hence, Functions Table was created to provide a single access point to extract these behaviors for __any__ data type.
Some functions are optional and others are needed in order for a collection to operate. Say you want a HashMap. There are two required functions: `hash` and `cmp` (comparator). Without them it is impossible to know how to hash your custom that type (it could be anything). This means you can also customize the collection by using different hash functions.
Many required functions are simply mundane. Like a comparator function between integers or between floats. The header [`utl/futils.h`](../../utl/futils.h/index.html) defines many of these functions for basic C data types.
Some collections generate two functions table. One for `K` and one for `V` (maps). Others simply generate one for `V`. A Functions Table `struct` is always going to be called:
* `struct SNAME##_fkey` for the `K` type
* `struct SNAME##_fval` for the `V` type
Their definition is defined as follows:
```c
\
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
\
/* Copy function */ \
K (*cpy)(K); \
\
/* To string function */ \
bool (*str)(FILE *, K); \
\
/* Free from memory function */ \
void (*free)(K); \
\
/* Hash function */ \
size_t (*hash)(K); \
\
/* Priority function */ \
int (*pri)(K, K); \
}; \
\
```
### CMP
* `K` - `int (*cmp)(K, K)`
* `V` - `int (*cmp)(V, V)`
A comparator function is used in sorted collections or when an equality is being checked like when trying to find a certain element in a list. It is responsible for taking two arguments of the same data type and comparing them. The return value is an `int` with the following definitions:
* Return `1` if the first argument is greater than the second;
* Return `0` if the first argument equals the second;
* Return `-1` if the first argument is less than the second.
Note that certain collections require a total ordering of its elements (sorted collections) while others only require to know if one data equals another. Check out the documentation for each collection to know more.
### CPY
* `K` - `K (*cpy)(K)`
* `V` - `V (*cpy)(V)`
A copy function is used when a collection is being copied. It can be used to make a deep copy of of your custom data type. It must take a single parameter and return a new copy of that same data type. If this function is absent (`NULL`) the data type will be copied by assignment (for pointers this is a shallow copy).
Note that it doesn't makes sense to define a `cpy` function for data types that are not pointers. This function is useful for deep copies of a pointer in case you don't want two collections holding the same reference to the data.
### STR
A string function is responsible for taking a `FILE` pointer and a custom data type and outputting the string representation of that data returning a `bool` indication success or failure. It is useful for debugging.
* `K` - `bool (*str)(FILE *, K)`
* `V` - `bool (*str)(FILE *, V)`
A string function is responsible for taking a `FILE` pointer and a custom data type and outputting the string representation of that data returning a `bool` indication success or failure. It is useful for debugging and doesn't necessarily needs to print all the data that the specific type holds.
### FREE
The free function is called when a collection is cleared (all elements removed) or freed (all elements removed and freed from memory) and it is responsible for completely freeing all resources that are usually acquired by your data type.
* `K` - `void (*free)(K)`
* `V` - `void (*free)(V)`
The free function is called when a collection is cleared (all elements removed) or freed (all elements removed and the collection is freed from memory) and it is responsible for completely freeing all resources that are usually acquired by your data type.
This function only makes sense to be used when the data type has dynamically allocated memory. It is the only completely optional function.
### HASH
This function receives a custom data type as parameter and returns a `size_t` hash of that data. Used in hashtables.
* `K` - `size_t (*hash)(K)`
* `V` - `size_t (*hash)(V)`
This function receives a custom data type as parameter and returns a `size_t` [hash](https://en.wikipedia.org/wiki/Hash_function) that represents that data. Used by collections with an underlying hash tables.
### PRI
A priority function works much like the comparator function except that it compares the priority between two elements. It is used in collections whose structure is based on the priority of elements and not in their general comparison.
* `K` - `int (*cmp)(K, K)`
* `V` - `int (*cmp)(V, V)`
A priority function works much like the comparator function except that it compares the priority between two elements. It is used in collections whose structure is based on the priority of elements and not in their general comparison (heaps).
* Return `1` if the first argument has a greater priority than the second;
* Return `0` if the first argument has the same priority as second;
* Return `-1` if the first argument has a lower priority than the second.
Why use both `cmp` and `pri`? Heaps have their internal structure based in the priority of elements. This priority is not necessarily how each element is compared to each other. Maybe their equality is defined differently for an equality of priorities. Maybe the rules for their priorities is different for when comparing an element against another.
The following table shows which functions are required, optional or never used for each Collection:
| Collection | CMP | CPY | STR | FREE | HASH | PRI |
+4
View File
@@ -0,0 +1,4 @@
# COR
Core functionalities of the C Macro Collections Library.
@@ -1,4 +1,4 @@
# Two-Way Iterators
# Iterators
Every collection comes with an interface of iterators where you can easily access the elements of a collection. These can move at any direction, can start at any 'end' of a collection and can move any amount of steps per iteration. Every collection generated comes with an iterator.
+3
View File
@@ -0,0 +1,3 @@
# DEV
The development collections. These collections are an exact copy of the `cmc` collections but they come with many logging throughout the generated code. Useful for debugging or during development.
+23
View File
@@ -0,0 +1,23 @@
# SAC
The Statically Allocated Collections. These collections have a fixed size. Its size is one of the parameters during macro expansion, producing a C array.
## CMC vs. SAC
The `cmc` collections hold their data either with nodes or a buffer that can be reallocated. The `sac` collections only have an array with fixed size and don't perform any allocation on the heap.
```c
// A CMC List
struct List
{
T *buffer;
/* Other fields */
};
// A SAC List
struct List
{
T buffer[SIZE];
/* Other fields */
};
```
@@ -1,2 +0,0 @@
# Array Assertion
@@ -0,0 +1,73 @@
# Generic Assertion Macros
## Contents
* [cmc_assert_array_equals_any](#cmc_assert_array_equals_any)
* [cmc_assert_array_within_any](#cmc_assert_array_within_any)
* [cmc_assert_array_outside_any](#cmc_assert_array_outside_any)
* [cmc_assert_array_sorted_any](#cmc_assert_array_sorted_any)
## cmc_assert_array_equals_any
Assert that two arrays are equal element by element. `from_index` and `to_index` are both inclusive.
```c
#define cmc_assert_array_equals_any(dtype, array1, array2, comparator, \
from_index, to_index)
```
* `dtype` - The type of the array. Can be of any data type.
* `array1` - First array to be compared
* `array2` - Second array to be compared
* `comparator` - A comparator function pointer that has two `dtype` arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second
* `from_index` - First index from both arrays to compare (inclusive)
* `to_index` - Last index from both arrays to compare (inclusive)
## cmc_assert_array_within_any
Assert that each element in the array are within a certain boundary. Both ends are inclusive.
```c
#define cmc_assert_array_within_any(dtype, array, comparator, lower_bound, \
upper_bound, from_index, to_index)
```
* `dtype` - The type of the array. Can be of any data type
* `array` - Array to be checked if its elements are within a given range
* `comparator` - A comparator function pointer that has two `dtype` arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second
* `lower_bound` - Smallest value of the given range
* `upper_bound` - Highest value of the given range
* `from_index` - First index from the array to compare (inclusive)
* `to_index` - Last index from the array to compare (inclusive)
## cmc_assert_array_outside_any
Assert that each element in the array are outside of a certain boundary. Both ends are inclusive.
```c
#define cmc_assert_array_outside_any(dtype, array, comparator, lower_bound, \
upper_bound, from_index, to_index)
```
* `dtype` - The type of the array. Can be of any data type
* `array` - Array to be checked if its elements are within a given range
* `comparator` - A comparator function pointer that has two `dtype` arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second
* `lower_bound` - Smallest value of the given range
* `upper_bound` - Highest value of the given range
* `from_index` - First index from the array to compare (inclusive)
* `to_index` - Last index from the array to compare (inclusive)
## cmc_assert_array_sorted_any
Asserts that an array is sorted.
```c
#define cmc_assert_array_sorted_any(dtype, array, comparator, from_index, \
to_index)
```
* `dtype` - The type of the array. Can be of any data type
* `array` - Array to be checked if it is sorted
* `comparator` - A comparator function pointer that has two `dtype` arguments and returns -1 if the first is less then the second, 0 if both are equal or 1 if the first is greater then the second
* `from_index` - First index from the array to compare (inclusive)
* `to_index` - Last index from the array to compare (inclusive)
+76 -2
View File
@@ -4,6 +4,80 @@ Definition of many typed non-abortive assertions. Every assertion that fails wil
The advantage of these typed macros is that when an assertion fails, it is possible to print to `stderr` the actual value that was passed to the function and check the expected result(s) all in one message.
There are assertions that work with a single value to be tested and others that work with arrays. Single value assertions work with a selected list of `dtype`, while the assertion with arrays work with any `dtype` that is a valid data type.
There are assertions that work with [predefined values](valued_assertions.html) and others that work with [generic values](generic_assertions.html). Valued assertions work with a selected list of `dtype` (see further below), while the generic assertions work with any data type.
The macro parameters can be an lvalue or an rvalue.
The macro parameters can be an *lvalue* or an *rvalue* because the parameters will be first assigned to local variables of the selected data type. Then, these local variables will be tested for whichever test that needs to be checked.
Assigning the macro parameter to a local variable can be useful. These local variables will be of type `dtype` and if the parameters don't match that type a warning will pop up.
Ever assertion is inside a block of `do { } while (0)`.
## Printed Messages
Whenever an assertion fails, a message will be printed to `stderr`. The message will look something like this:
```
Assertion Failed at FILE:FUNCTION:LINE for { ACTUAL }: DETAILS
```
The first information is the file where that assertion failed. Then the function name and the line number. Then in place of `ACTUAL`, a stringified version of the `actual` parameter, which is the variable being checked in the assertion, will be printed.
In `DETAILS` is where more information about the assertion will be printed. This is the most useful part of these macros. In here, the actual value of the variable will be printed along with the expected value or range or lower bound, etc. __In here you will be able to debug your application to check the expected value(s) against the actual one.__
__Example__
```c
#include "utl/assert.h"
void is_one_hundred(int variable)
{
cmc_assert_equals(int32_t, 100, variable);
}
int main(void)
{
int my_var = 9;
is_one_hundred(my_var);
}
```
This will print the following message:
`Assertion Failed at main.c:is_one_hundred:5 for { variable }: Expected: 100 Actual: 9`
## cmc_assert_state
This is a global variable that can be used to test if all assertions passed. If any assertion fails, this variable will be set to `false`. If an assertion passes this variable will __not__ be set back to `true`. If you wish to, you can set the state back to `true` manually.
```c
static bool cmc_assert_state = true;
```
This variable is used in [test.h](../test.h/index.html) utility to automatically pass or fail a unit test. Once the unit test finishes, this variable is set back to `true` so that another unit test may follow.
## dtype
These are the data types supported by the Valued Assertion macros:
* `int8_t`
* `int16_t`
* `int32_t`
* `int64_t`
* `uint8_t`
* `uint16_t`
* `uint32_t`
* `uint64_t`
* `intmax_t`
* `uintmax_t`
* `size_t`
* `float`
* `double`
The following two are only accepted by `cmc_assert_equals` and `cmc_assert_not_equals`:
* `ptr`
* `bool`
Note that `ptr` is used for any pointers. They are first casted to `void *` and then their address is compared.
Note that bool will be expanded to `_Bool`.
+13 -38
View File
@@ -2,44 +2,19 @@
## Single Value Assertion Macros
* cmc_assert
* cmc_assert_equals
* cmc_assert_not_equals
* cmc_assert_greater
* cmc_assert_greater_equals
* cmc_assert_lesser
* cmc_assert_lesser_equals
* cmc_assert_in_range
* cmc_assert_not_in_range
* __cmc_assert__ - Asserts that an expression evaluates to true;
* __cmc_assert_equals__ - Asserts that a value from type `dtype` equals another;
* __cmc_assert_not_equals__ - Asserts that value from type `dtype` does not equals another;
* __cmc_assert_greater__ - Asserts that a value from type `dtype` is greater than a lower bound;
* __cmc_assert_greater_equals__ - Asserts that a value from type `dtpype` is greater than or equal to a lower bound;
* __cmc_assert_lesser__ - Asserts that a value from type `dtpype` is lesser than an upper bound;
* __cmc_assert_lesser_equals__ - Asserts that a value from type `dtpype` is lesser than or equal to an upper bound;
* __cmc_assert_in_range__ - Asserts that a value from type `dtpype` is within a certain range;
* __cmc_assert_not_in_range__ - Asserts that a value from type `dtpype` is outside of a certain range.
## Array Assertion Macros
* cmc_assert_array_equals_any
* cmc_assert_array_within_any
* cmc_assert_array_outside_any
* cmc_assert_array_sorted_any
## dtype
These are the data types supported by the single value assertion macros:
* int8_t
* int16_t
* int32_t
* int64_t
* uint8_t
* uint16_t
* uint32_t
* uint64_t
* intmax_t
* uintmax_t
* size_t
* float
* double
The following two are only accepted by `cmc_assert_equals` and `cmc_assert_not_equals`:
* ptr
* bool
Note that `ptr` is used for any pointers. They are first casted to `void *` and then their address is compared.
* __cmc_assert_array_equals_any__ - Assert that two arrays are equal element by element;
* __cmc_assert_array_within_any__ - Assert that each element in the array are within a bounds;
* __cmc_assert_array_outside_any__ - Assert that each element in the array are out of bounds;
* __cmc_assert_array_sorted_any__ - Assert that the array is sorted.
@@ -1,29 +0,0 @@
# Single Value Assertion Macros
## cmc_assert_state
This is a global variable that can be used to test if all assertions passed. If a single assertion fails, this variable will be set to `false`. If an assertion passes this variable will not be set back to `true`.
```c
static bool cmc_assert_state = true;
```
This variable is used in [test.h](./test.html) utility to automatically pass or fail a unit test. Once the unit test finishes, this variable is set back to `true` so that another unit test may follow.
## cmc_assert
Asserts that an expression evaluates to `true`.
```c
#define cmc_assert(expression)
```
### Parameters
* `expression` - An expression that needs to be evaluated to true.
## cmc_assert_equals
Asserts that a
@@ -0,0 +1,127 @@
# Valued Assertion Macros
## Contents
* [cmc_assert](#cmc_assert)
* [cmc_assert_equals](#cmc_assert_equals)
* [cmc_assert_not_equals](#cmc_assert_not_equals)
* [cmc_assert_greater](#cmc_assert_greater)
* [cmc_assert_greater_equals](#cmc_assert_greater_equals)
* [cmc_assert_lesser](#cmc_assert_lesser)
* [cmc_assert_lesser_equals](#cmc_assert_lesser_equals)
* [cmc_assert_in_range](#cmc_assert_in_range)
* [cmc_assert_not_in_range](#cmc_assert_not_in_range)
## cmc_assert
Asserts that an `expression` evaluates to `true`.
```c
#define cmc_assert(expression)
```
__Parameters__
* `expression` - An expression that needs to be evaluated to true.
## cmc_assert_equals
Asserts that a value equals another expected value.
```c
#define cmc_assert_equals(dtype, expected, actual)
```
__Parameters__
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `expected` - The expected value for this assertion
* `actual` - A variant that is checked against the expected value
## cmc_assert_not_equals
Asserts that a value does not equal another.
```c
#define cmc_assert_not_equals(dtype, not_expected, actual)
```
__Parameters__
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `not_expected` - The value that is not expected for this assertion
* `actual` - A variant that is checked against the not expected value
## cmc_assert_greater
Asserts that a value is above a certain lower boundary.
```c
#define cmc_assert_greater(dtype, boundary, actual)
```
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `boundary` - The expected lowest possible value (excluded)
* `actual` - A variant that is checked against the boundary value
## cmc_assert_greater_equals
Asserts that a value is above a certain lower boundary or equal to it.
```c
#define cmc_assert_greater_equals(dtype, boundary, actual)
```
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `boundary` - The expected lowest possible value (included)
* `actual` - A variant that is checked against the boundary value
## cmc_assert_lesser
Asserts that a value is below a certain upper boundary.
```c
#define cmc_assert_lesser(dtype, boundary, actual)
```
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `boundary` - The expected highest possible value (excluded)
* `actual` - A variant that is checked against the boundary value
## cmc_assert_lesser_equals
Asserts that a value is below a certain upper boundary or equal to it.
```c
#define cmc_assert_lesser_equals(dtype, boundary, actual)
```
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `boundary` - The expected highest possible value (excluded)
* `actual` - A variant that is checked against the boundary value
## cmc_assert_in_range
Asserts that a value is within a certain range. Range is inclusive on both ends.
```c
#define cmc_assert_in_range(dtype, lower_bound, upper_bound, actual)
```
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `lower_bound` - Smallest value of the expected range
* `upper_bound` - Highest value of the expected range
* `actual` - A variant that is checked against lower and upper boundaries value
## cmc_assert_not_in_range
Asserts that a value is not within a certain range. Range is inclusive on both ends.
```c
#define cmc_assert_not_in_range(dtype, lower_bound, upper_bound, actual)
```
* `dtype` - One of the possible data types listed [here](index.html#dtype)
* `lower_bound` - Smallest value of the not expected range
* `upper_bound` - Highest value of the not expected range
* `actual` - A variant that is checked against lower and upper boundaries value
-7
View File
@@ -1,7 +0,0 @@
# assert.h
Definition of many typed non-abortive assertions. Every assertion that fails will print a message to `stderr` but will not abort the program execution. The macro parameters are first assigned to a temporary variable of the specified `dtype` in order to generate warnings from the compiler in case of type mismatch.
The advantage of these typed macros is that when an assertion fails, it is possible to print to `stderr` the actual value that was passed to the function and check the expected result(s) all in one message.
There are assertions that work with a single value to be tested and others that work with arrays. Single value assertions work with a selected list of `dtype`, while the assertion with arrays work with any `dtype` that is a valid data type.
+60
View File
@@ -0,0 +1,60 @@
# foreach.h
For-Each macros. Since doing a for loop with iterators can be a lot to write, these macros solve that problem. There are two of them:
* `CMC_FOREACH` - Goes from the beginning of a Collection to the end
* `CMC_FOREAC_REV` - Goes from the end of a Collection to the beginning
## CMC_FOREACH
```c
#define CMC_FOREACH(PFX, SNAME, ITERNAME, TARGET)
```
* `PFX` - Functions prefix
* `SNAME` - Struct name
* `ITERNAME` - Iterator variable name
* `TARGET` - Target collection variable name
## CMC_FOREACH_REV
```c
#define CMC_FOREACH_REV(PFX, SNAME, ITERNAME, TARGET)
```
* `PFX` - Functions prefix
* `SNAME` - Struct name
* `ITERNAME` - Iterator variable name
* `TARGET` - Target collection variable name
## Example
```c
#include "cmc/list.h"
#include "utl/foreach.h"
CMC_GENERATE_LIST(i32l, i32list, int32_t)
int main(void)
{
struct i32list *list = i32l_new(100, &(struct i32list_fval) { NULL });
for (int i = 0; i < 100; i++)
i32l_push_back(list, i);
CMC_FOREACH(i32l, i32list, it, list)
{
int value = i32l_iter_value(&it);
size_t index = i32l_iter_index(&it);
if (index == 0)
printf("[ %d, ", value);
else if (index == i32l_count(list) - 1)
printf("%d ]\n", value);
else
printf("%d, ", value);
}
i32l_free(list);
}
```
-13
View File
@@ -1,13 +0,0 @@
# foreach.md
For-Each macros. Since doing a for loop with iterators can be a lot to write, these macros solve that problem. There are two of them:
* `CMC_FOREACH` - Goes from the beginning of a Collection to the end
* `CMC_FOREAC_REV` - Goes from the end of a Collection to the beginning
## Parameters
* `PFX` - Functions prefix
* `SNAME` - Struct name
* `ITERNAME` - Iterator variable name
* `TARGET` - Target variable
+87
View File
@@ -0,0 +1,87 @@
# futils.h
Contains common functions that can be used by Functions Table, instead of writing another one every time.
A quick list of functions present in this file:
| cmp |
| ----------- |
| `static inline int cmc_i64_cmp(int64_t x1, int64_t x2);` |
| `static inline int cmc_i32_cmp(int32_t x1, int32_t x2);` |
| `static inline int cmc_i16_cmp(int16_t x1, int16_t x2);` |
| `static inline int cmc_i8_cmp(int8_t x1, int8_t x2);` |
| `static inline int cmc_u64_cmp(uint64_t x1, uint64_t x2);` |
| `static inline int cmc_u32_cmp(uint32_t x1, uint32_t x2);` |
| `static inline int cmc_u16_cmp(uint16_t x1, uint16_t x2);` |
| `static inline int cmc_u8_cmp(uint8_t x1, uint8_t x2);` |
| `static inline int cmc_size_cmp(size_t x1, size_t x2);` |
| `static inline int cmc_imax_cmp(intmax_t x1, intmax_t x2);` |
| `static inline int cmc_umax_cmp(uintmax_t x1, uintmax_t x2);` |
| `static inline int cmc_float_cmp(float x1, float x2);` |
| `static inline int cmc_double_cmp(double x1, double x2);` |
| `static inline int cmc_str_cmp(char *ch1, char *ch2);` |
<br>
<br>
| cpy |
| --- |
| `static inline char *cmc_str_cpy(char *str);` |
<br>
<br>
| str |
| --- |
| `static inline bool cmc_i8_str(FILE *file, int8_t element);` |
| `static inline bool cmc_i16_str(FILE *file, int16_t element);` |
| `static inline bool cmc_i32_str(FILE *file, int32_t element);` |
| `static inline bool cmc_i64_str(FILE *file, int64_t element);` |
| `static inline bool cmc_u8_str(FILE *file, uint8_t element);` |
| `static inline bool cmc_u16_str(FILE *file, uint16_t element);` |
| `static inline bool cmc_u32_str(FILE *file, uint32_t element);` |
| `static inline bool cmc_u64_str(FILE *file, uint64_t element);` |
| `static inline bool cmc_size_str(FILE *file, size_t element);` |
| `static inline bool cmc_imax_str(FILE *file, intmax_t element);` |
| `static inline bool cmc_umax_str(FILE *file, uintmax_t element);` |
| `static inline bool cmc_float_str(FILE *file, float element);` |
| `static inline bool cmc_double_str(FILE *file, double element);` |
| `static inline bool cmc_str_str(FILE *file, char *element);` |
<br>
<br>
| free |
| --- |
<br>
<br>
| hash |
| ---- |
| `static inline size_t cmc_i64_hash(int64_t e);` |
| `static inline size_t cmc_i32_hash(int32_t e);` |
| `static inline size_t cmc_i16_hash(int16_t e);` |
| `static inline size_t cmc_i8_hash(int8_t e);` |
| `static inline size_t cmc_u64_hash(uint64_t e);` |
| `static inline size_t cmc_u32_hash(uint32_t e);` |
| `static inline size_t cmc_u16_hash(uint16_t e);` |
| `static inline size_t cmc_u8_hash(uint8_t e);` |
| `static inline size_t cmc_size_hash(size_t e);` |
| `static inline size_t cmc_imax_hash(intmax_t e);` |
| `static inline size_t cmc_umax_hash(uintmax_t e);` |
| `static inline size_t cmc_float_hash(float e);` |
| `static inline size_t cmc_double_hash(double e);` |
| `static inline size_t cmc_str_hash_djb2(char *str);` |
| `static inline size_t cmc_str_hash_sdbm(char *str);` |
| `static inline size_t cmc_str_hash_java(char *str);` |
| `static inline size_t cmc_str_hash_murmur3(uint64_t e);` |
| `static inline size_t cmc_str_hash_murmur3_variant(uint64_t e);` |
| `static inline size_t cmc_i64_hash_mix(int64_t element);` |
| `static inline size_t cmc_u64_hash_mix(uint64_t element);` |
<br>
<br>
| pri |
| --- |
+12
View File
@@ -0,0 +1,12 @@
# UTL
Inside the `./utl/` folder there are many utility functions and macros that can be extensively used with the C Macro Collections library. Most of these utilities can be used without the main library.
## Contents
* [assert.h](assert.h/index.html) - Non-abortive assert macros
* [foreach.h](foreach.h/index.html) - For Each macros
* [futils.h](futils.h/index.html) - Common functions used by Functions Table
* [log.h](log.h/index.html) - Logging utility with levels of severity
* [test.h](test.h/index.html) - Simple Unit Test building with macros
* [timer.h](timer.h/index.html) - Timing code execution utility
+62
View File
@@ -0,0 +1,62 @@
# Configuration
## cmc_log_config
This is an anonymous static `struct` that can be directly modified to change logging levels, enable or disable output or change file output.
```c
static struct
{
enum cmc_log_type tlevel;
enum cmc_log_type flevel;
bool tenabled;
bool fenabled;
bool enabled;
FILE * file;
} cmc_log_config = { 0, 0, true, true, true, NULL };
```
__Members__
* `tlevel` - Terminal log level (`stderr`)
* `flevel` - File log level
* `tenabled` - Terminal logging enabled if `true`
* `fenabled` - File logging enabled if `true`
* `enabled` - Enables or disables all logs
* `FILE *file` - File for output
This configuration is global to every log. The `FILE` pointer is not handled by the API and needs to be able to write to the file.
## Log Level
By tuning `tlevel` and `flevel` (both accessed from `cmc_log_config`) you can filter which log messages are printed or not.
* If the log level is `0`, all logs are enabled
* If the log level `X` is positive:
* All levels less than `X` will be disabled
* If `X` is greater than the level of `FATAL`, all logs are disabled
* If the log level `X` is negative:
* All levels greater than `abs(X)` are enabled
* If `abs(X)` is greater than the level of `FATAL`, all logs are enabled
__Examples__
If you want to output only `TRACE` logs to a file and the rest to `stderr`:
* `cmc_log_config.tlevel = CMC_LOG_DEBUG`
* `cmc_log_config.flevel = -CMC_LOG_TRACE`
If you want to output only `FATAL` to `stderr` and the rest to a file:
* `cmc_log_config.tlevel = CMC_LOG_FATAL`
* `cmc_log_config.flevel = -CMC_LOG_ERROR`
If you want to output only `FATAL` and `ERROR` to a file an nothing to `stderr`:
* `cmc_log_config.tlevel = CMC_LOG_FATAL + 1`
* `cmc_log_config.flevel = CMC_LOG_ERROR`
__Summary__
* Log Level > 0: "Allow all log levels that are greater than this, including it"
* Log Level < 0: "Allow all log levels that are smaller than this, including it"
+23
View File
@@ -0,0 +1,23 @@
# log.h
Simple and customizable logging macros. Messages can have a custom logging level and a custom file output. This customization can be done via the global variable [`cmc_log_config`](configuration.html#cmc_log_config). Logs are outputted to `stderr`.
## cmc_log_type
Defines the possible Log Levels. These are used to categorize log messages. The higher the number, the more severe or important that message is. Check out [here](meanings.html)
```c
enum cmc_log_type
{
CMC_LOG_TRACE = 1,
CMC_LOG_DEBUG = 2,
CMC_LOG_INFO = 3,
CMC_LOG_WARN = 4,
CMC_LOG_ERROR = 5,
CMC_LOG_FATAL = 6
};
```
## CMC_LOG_COLOR
If this macro is defined, logging will be outputted with [ANSI color escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors). If you are logging into a file, these escape codes are not printed.
+67
View File
@@ -0,0 +1,67 @@
# Log Functions
## cmc_log_trace
Defines a message with a Log Level of `CMC_LOG_TRACE`.
```c
#define cmc_log_trace(fmt, ...)
```
* `fmt` - A string that contains a text to be written that may contain format specifiers
* `...` - Optional. Values to be formatted into the string that will be printed
## cmc_log_debug
Defines a message with a Log Level of `CMC_LOG_DEBUG`.
```c
#define cmc_log_debug(fmt, ...)
```
* `fmt` - A string that contains a text to be written that may contain format specifiers
* `...` - Optional. Values to be formatted into the string that will be printed
## cmc_log_info
Defines a message with a Log Level of `CMC_LOG_INFO`.
```c
#define cmc_log_info(fmt, ...)
```
* `fmt` - A string that contains a text to be written that may contain format specifiers
* `...` - Optional. Values to be formatted into the string that will be printed
## cmc_log_warn
Defines a message with a Log Level of `CMC_LOG_WARN`.
```c
#define cmc_log_warn(fmt, ...)
```
* `fmt` - A string that contains a text to be written that may contain format specifiers
* `...` - Optional. Values to be formatted into the string that will be printed
## cmc_log_error
Defines a message with a Log Level of `CMC_LOG_ERROR`.
```c
#define cmc_log_error(fmt, ...)
```
* `fmt` - A string that contains a text to be written that may contain format specifiers
* `...` - Optional. Values to be formatted into the string that will be printed
## cmc_log_fatal
Defines a message with a Log Level of `CMC_LOG_FATAL`.
```c
#define cmc_log_fatal(fmt, ...)
```
* `fmt` - A string that contains a text to be written that may contain format specifiers
* `...` - Optional. Values to be formatted into the string that will be printed
+10
View File
@@ -0,0 +1,10 @@
# Meanings
What does each Log Level means? It depends on the application. In here you will read more about how the C Macro Collections library uses each of these Log Levels, but this does not mean you should use them like described.
* __TRACE__ - Trace is used to describe the inner workings of a function or an algorithm. These messages can be used extensively, meaning that their content is probably not very useful, even for debugging.
* __DEBUG__ - Mainly used for debugging, tracking certain variables, checking if pointers were deallocated or anything useful to help visualizing what your program is doing in general.
* __INFO__ - Info can be used as a heads up. Something that is important to note, but is not quite a warning or an error.
* __WARN__ - Warnings are attributed to all cases where the function can recover from and usually treated by it. In most cases the user can treat these warnings himself.
* __ERROR__ - Something really bad happened. Your program will not crash yet but depending on what comes next, it will. This might be attributed to pointers that shouldn't be null because later functions might use it.
* __FATAL__ - This will probably be the last logging message before your program crashes or goes into madness. Fatal errors are commonly attributed to dereferencing NULL pointers.
-3
View File
@@ -1,3 +0,0 @@
# log.h
Logging utility.
+118
View File
@@ -0,0 +1,118 @@
# test.h
A simple [Unit Test](https://en.wikipedia.org/wiki/Unit_testing) utility used by the C Macro Collections Library. It has two main components: a Unit and a Test.
This utility uses two other libraries defined in the C Macro Collections library:
* [`assert.h`](../assert.h/index.html)
* [`timer.h`](../timer.h/index.html)
When a test is created inside a unit, it will first set the global variable [`cmc_assert_state`](../assert.h/index.html#cmc_assert_state) to `true`. Then, inside the test you can use the assertions provided by the `assert.h` library to pass or fail a unit test automatically. By the end of a test the variable will be checked. If `false` it means that a certain assertion failed.
The runtime of each Unit Test is calculated using the `timer.h` library.
## CMC_CREATE_UNIT
Creates a Unit that can contain tests.
```c
#define CMC_CREATE_UNIT(UNAME, VERBOSE, BODY)
```
* `UNAME` - Unit name. This needs to be a valid function name!
* `VERBOSE` - Either `true` or `false`. If `true`, prints every message of `PASSED` or `FAILED` from each test
* `BODY` - A block of code containing tests
## CMC_CREATE_TEST
Creates a test within a unit. This macro can only be used inside the `BODY` of a `CMC_CREATE_UNIT` since it uses local variables allocated by the latter.
```c
#define CMC_CREATE_TEST(TNAME, BODY)
```
* `TNAME` - Test name
* `BODY` - A block of code containing the test itself
Inside a test you can use the assertions from `assert.h` to automatically pass or fail a test.
## CMC_TEST_ABORT
Aborts a unit test. This will jump to a `goto` located at the end of the Unit Test. Must be called inside a `CMC_CREATE_TEST`.
```c
#define CMC_TEST_ABORT()
```
## cmc_test_info
Contains information about a Unit Test. Used internally.
```c
struct cmc_test_info
{
uintmax_t total;
uintmax_t passed;
uintmax_t failed;
uintmax_t assert_total;
uintmax_t assert_failed;
bool aborted;
bool verbose;
};
```
* `uintmax_t total` - Total tests in the unit test
* `uintmax_t passed` - Total tests passed in the unit test
* `uintmax_t failed` - Total tests failed in the unit test
* `uintmax_t assert_total` - Total assertions in the unit test
* `uintmax_t assert_failed` - Total assertions failed in the unit test
* `bool aborted` - If the unit test was aborted
* `bool verbose` - Information about each test is displayed
## CMC_TEST_COLOR
Define this macro if you wish to have color output from the messages printed by each test. Note that a Unit Test need to have `VERBOSE` equal to `true`.
## Example
```c
#include "utl/test.h"
CMC_CREATE_UNIT(check_math, true, {
CMC_CREATE_TEST(summation, {
// assert.h already comes with test.h
cmc_assert_equals(int32_t, 4, 2 + 2);
});
CMC_CREATE_TEST(subtraction, {
cmc_assert_equals(int32_t, -1, 2 - 3);
});
CMC_CREATE_TEST(this will fail, {
// test names can be text as long as they don't have a comma
cmc_assert_greater(double, 1.0, 0.0);
});
CMC_CREATE_TEST(fish, {
// You can also manually fail a test
if (strcmp("2 + 2", "fish") != 0)
cmc_assert_state = false;
});
CMC_CREATE_TEST(abort!, {
if (4 % 2 == 0)
CMC_TEST_ABORT();
});
CMC_CREATE_TEST(sad..., {
// This test won't be called because unit test was aborted above
cmc_assert(true);
});
});
int main(void)
{
// returns how many tests failed
return check_math();
}
```
-4
View File
@@ -1,4 +0,0 @@
# test.h
Simple unit test utility.
+63
View File
@@ -0,0 +1,63 @@
# timer.h
A very simple library that encapsulates `clock()` from `<time.h>`, making life easier.
## cmc_timer
```c
struct cmc_timer
{
clock_t start;
clock_t stop;
double result;
};
```
* `clock_t start` - Start of timing
* `clock_t stop` - End of timing
* `double result` - Result in milliseconds
## cmc_timer_start
Starts the timer by setting `start` with `clock()`.
```c
#define cmc_timer_start(timer)
```
* `timer` - A `struct cmc_timer` variable
## cmc_timer_stop
Sets the `stop` variable with `clock()` and calculates the `result` in milliseconds.
```c
#define cmc_timer_start(timer)
```
* `timer` - A `struct cmc_timer` variable
## Example
```c
#include <stdio.h>
#include "utl/timer.h"
int main(void)
{
struct cmc_timer t;
cmc_timer_start(t);
size_t total = 0;
for (size_t i = 0; i < 1000000000; i++)
total += i;
cmc_timer_stop(t);
printf("Sum took %.0lf milliseconds to calculate\n", t.result);
}
```
-3
View File
@@ -1,3 +0,0 @@
# timer.h
Simple code execution utility.
Loaded 100 of 276 files, more files were not shown because too many files have changed in this diff. Show more