76 Commits
Author SHA1 Message Date
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
195 changed files with 34945 additions and 17851 deletions

No files matched your search

+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
- name: Test Suite
run: make -C ./tests/main nocov
- name: Valgrind Test
run: make -C ./tests/main valgrind
-1
View File
@@ -14,6 +14,5 @@ script:
- export CC=gcc-7
# - make -C ./tests/
- make -C ./tests/main/
- make -C ./tests/codecov/
after_success:
- bash <(curl -s https://codecov.io/bash)
+46 -29
View File
@@ -1,6 +1,23 @@
# RELEASE.MAJOR.MINOR
1.8.0
0.23.0
Added ./cmc/bitset.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 +31,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 +48,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 +67,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 +75,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 +89,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 +102,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 +122,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 +131,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 +139,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 +156,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 +206,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
+5 -2
View File
@@ -2,11 +2,14 @@
.PHONY: all cmc dev sac utl tests FORCE
all: cmc dev sac utl tests
all: cmc cor dev sac utl tests
cmc: FORCE
clang-format --style=file -i ./src/cmc/*.h
cor: FORCE
clang-format --style=file -i ./src/cor/*.h
dev: FORCE
clang-format --style=file -i ./src/dev/*.h
@@ -17,6 +20,6 @@ utl: FORCE
clang-format --style=file -i ./src/utl/*.h
tests: FORCE
clang-format --style=file -i ./tests/main/unt/*.c ./tests/*.c
clang-format --style=file -i ./tests/main/unt/*.c ./tests/main/main.c ./tests/*.c
FORCE:
+39 -27
View File
@@ -1,21 +1,22 @@
# 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.23.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
@@ -31,8 +32,8 @@
## 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
@@ -48,29 +49,40 @@
* Linear Collections
* List, LinkedList, Deque, Stack, Queue, SortedList
* Sets
* HashSet, TreeSet, MultiSet
* HashSet, TreeSet, HashMultiSet
* Maps
* BidiMap, HashMap, TreeMap, MultiMap
* HashMap, TreeMap, HashMultiMap
* Bidirectional Maps
* HashBidiMap
* Heaps
* Heap, IntervalHeap
* WIP
* BitSet, Matrix, TreeBidiMap, TreeMultiMap, TreeMultiSet
__The following table is an overview of all the currently available or upcoming data structures__:
| 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 |
| 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 |
| Matrix <br> _WIP_ | Regular Matrix | Dynamic Array of Dynamic Arrays | A regular matrix with arbitrary rows and columns |
| 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 |
| 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 |
## Features
@@ -126,16 +138,16 @@ The following table shows which functions are required, optional or never used f
| 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=+) |
| 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=+) |
+1 -1
View File
@@ -26,7 +26,6 @@ TODO
[ ] 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])
#!! Done -------------------------------------------------------------------------------------------
@@ -62,3 +61,4 @@ 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])
+101
View File
@@ -0,0 +1,101 @@
# A script that automatically expands the macros for code coverage
import os
import re
import subprocess
# Compiler settings
CC = 'gcc'
INCLUDE = '-I ./src'
# -E Only preprocessor
# -P No linemarkers
# -C Keep comments, except those inside macros (for UNIQUE_FLAG)
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'
# Output directory
OUTPUT_DIR = './tests/main/src'
collections = [
# type, header, pfx, sname, key, val
{'t': 'BITSET', 'h': '"cmc/bitset.h"', 'pfx': 'bs', 'sname': 'bitset', 'key': '', 'val': '' },
{'t': 'DEQUE', 'h': '"cmc/deque.h"', 'pfx': 'd', 'sname': 'deque', 'key': '', 'val': 'size_t'},
{'t': 'HASHBIDIMAP', 'h': '"cmc/hashbidimap.h"', 'pfx': 'hbm', 'sname': 'hashbidimap', 'key': 'size_t', 'val': 'size_t'},
{'t': 'HASHMAP', 'h': '"cmc/hashmap.h"', 'pfx': 'hm', 'sname': 'hashmap', 'key': 'size_t', 'val': 'size_t'},
{'t': 'HASHMULTIMAP', 'h': '"cmc/hashmultimap.h"', 'pfx': 'hmm', 'sname': 'hashmultimap', 'key': 'size_t', 'val': 'size_t'},
{'t': 'HASHMULTISET', 'h': '"cmc/hashmultiset.h"', 'pfx': 'hms', 'sname': 'hashmultiset', 'key': '', 'val': 'size_t'},
{'t': 'HASHSET', 'h': '"cmc/hashset.h"', 'pfx': 'hs', 'sname': 'hashset', 'key': '', 'val': 'size_t'},
{'t': 'HEAP', 'h': '"cmc/heap.h"', 'pfx': 'h', 'sname': 'heap', 'key': '', 'val': 'size_t'},
{'t': 'INTERVALHEAP', 'h': '"cmc/intervalheap.h"', 'pfx': 'ih', 'sname': 'intervalheap', 'key': '', 'val': 'size_t'},
{'t': 'LINKEDLIST', 'h': '"cmc/linkedlist.h"', 'pfx': 'll', 'sname': 'linkedlist', 'key': '', 'val': 'size_t'},
{'t': 'LIST', 'h': '"cmc/list.h"', 'pfx': 'l', 'sname': 'list', 'key': '', 'val': 'size_t'},
{'t': 'QUEUE', 'h': '"cmc/queue.h"', 'pfx': 'q', 'sname': 'queue', 'key': '', 'val': 'size_t'},
{'t': 'SORTEDLIST', 'h': '"cmc/sortedlist.h"', 'pfx': 'sl', 'sname': 'sortedlist', 'key': '', 'val': 'size_t'},
{'t': 'STACK', 'h': '"cmc/stack.h"', 'pfx': 's', 'sname': 'stack', 'key': '', 'val': 'size_t'},
{'t': 'TREEMAP', 'h': '"cmc/treemap.h"', 'pfx': 'tm', 'sname': 'treemap', 'key': 'size_t', 'val': 'size_t'},
{'t': 'TREESET', 'h': '"cmc/treeset.h"', 'pfx': 'ts', 'sname': 'treeset', 'key': '', 'val': 'size_t'}
]
# Create output directory
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
for data in collections:
file = open(TMP_FILE, 'w')
if data['key'] == '' and data['val'] == '':
# bitset, no K and no V
type_params = ''
elif data['key'] != '':
# maps, K and V
type_params = f', {data["key"]}, {data["val"]}'
else:
# only V
type_params = f', {data["val"]}'
file.write(
f'''
#include {data['h']}
{UNIQUE_FLAG}
CMC_GENERATE_{data['t']}({data['pfx']}, {data['sname']}{type_params})
{UNIQUE_FLAG}
''')
file.flush()
file.close()
result = subprocess.getoutput(f'{CC} {FLAGS} {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.')
exit(1)
file = open(f'{OUTPUT_DIR}/{data["sname"]}.c', 'w')
file.write(f'#include {data["h"]}\n{match.group("code")}')
file.flush()
file.close()
print(f'Generated {data["h"]: >20} -> {OUTPUT_DIR}/{data["sname"]}.c')
os.remove(TMP_FILE)
# Format all files
print('Formating files...')
subprocess.call(['clang-format', '--style=file', '-i', f'{OUTPUT_DIR}/*.c'])
print('Done')
+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.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>
<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>Custom allocation - 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" 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" 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,27 +148,28 @@
<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>
<ul>
<li><code>calloc</code></li>
<li><code>free</code></li>
<li><code>malloc</code></li>
<li><code>realloc</code></li>
</ul>
<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>
</main>
<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/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/callbacks.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>
@@ -180,13 +181,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/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/callbacks.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>foreach.h - 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"><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" 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,18 +148,46 @@
<div id="content" class="content">
<main>
<h1><a class="header" href="#foreachmd" id="foreachmd">foreach.md</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>
<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>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>
<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>
<h2><a class="header" href="#parameters" id="parameters">Parameters</a></h2>
</li>
<li><code>./cor</code> - Core functionalities of the C Macro Collections libraries
<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>./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>
@@ -167,13 +195,13 @@
<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="../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="../utl/log.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>
@@ -185,13 +213,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="../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="../utl/log.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>Callbacks - 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"><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"><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,29 +148,21 @@
<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>
</tbody></table>
<p>Check the documentation for each collection to see which functions call which callbacks.</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/custom_allocation.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/functions_table.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>
@@ -182,13 +174,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/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/functions_table.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.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>
<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
@@ -3,7 +3,7 @@
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Two way iterators - C Macro Collections</title>
<title>sac - 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"><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>
@@ -148,22 +148,37 @@
<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="#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="../Features/features.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<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="../Features/custom_allocation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<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>
@@ -175,13 +190,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="../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="../Features/custom_allocation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<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>
+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>
+272
View File
@@ -0,0 +1,272 @@
<!DOCTYPE HTML>
<html lang="en" class="sidebar-visible no-js light">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>foreach.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" 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>
<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="#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="#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 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/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/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>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<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/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>
</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>
+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.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>
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.
-3
View File
@@ -1,3 +0,0 @@
# 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.
+587
View File
@@ -0,0 +1,587 @@
/**
* bitset.h
*
* Creation Date: 30/04/2020
*
* Authors:
* Leonardo Vencovsky (https://github.com/LeoVen)
*
*/
/**
* BitSet
*
* 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).
*
* Implementation
*
* This BitSet implementation uses an array of type cmc_bitset_word which can be
* typedefed 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.
*/
#ifndef CMC_BITSET_H
#define CMC_BITSET_H
/* -------------------------------------------------------------------------
* Core functionalities of the C Macro Collections Library
* ------------------------------------------------------------------------- */
#include "../cor/core.h"
/* -------------------------------------------------------------------------
* BitSet specific
* ------------------------------------------------------------------------- */
/* Defines the underlaying data type for the bitset array */
/* Possible values: uint64_t, uint32_t, uint16_t, uint8_t, size_t */
#ifndef CMC_BITSET_WORD_TYPE
#define CMC_BITSET_WORD_TYPE uint32_t
#endif /* CMC_BITSET_WORD_TYPE */
typedef CMC_BITSET_WORD_TYPE cmc_bitset_word;
/* to_string format */
static const char *cmc_string_fmt_bitset = "struct %s "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"flag:%d, "
"alloc:%p, "
"callbacks:%p }";
#define CMC_GENERATE_BITSET(PFX, SNAME) \
CMC_GENERATE_BITSET_HEADER(PFX, SNAME) \
CMC_GENERATE_BITSET_SOURCE(PFX, SNAME)
#define CMC_WRAPGEN_BITSET_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_BITSET_HEADER(PFX, SNAME)
#define CMC_WRAPGEN_BITSET_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_BITSET_SOURCE(PFX, SNAME)
/* -------------------------------------------------------------------------
* Header
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_BITSET_HEADER(PFX, SNAME) \
\
/* BitSet Structure */ \
struct SNAME \
{ \
/* Dynamic Array of Bits */ \
cmc_bitset_word *buffer; \
\
/* Current array capacity */ \
size_t capacity; \
\
/* Flags indicating errors or success */ \
int flag; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
}; \
\
/* BitSet Iterator */ \
struct SNAME##_iter \
{ \
/* Target bitset */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
cmc_bitset_word cursor; \
\
/* If the iterator has reached the start of the iteration */ \
bool start; \
\
/* If the iterator has reached the end of the iteration */ \
bool end; \
}; \
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t n_bits); \
struct SNAME *PFX##_new_custom(size_t n_bits, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
struct SNAME PFX##_init(size_t n_bits); \
struct SNAME PFX##_init_custom(size_t n_bits, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_free(struct SNAME *_bitset_); \
void PFX##_release(struct SNAME _bitset_); \
void PFX##_customize(struct SNAME *_bitset_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_set(struct SNAME *_bitset_, size_t bit_index); \
bool PFX##_set_range(struct SNAME *_bitset_, size_t from, size_t to); \
bool PFX##_clear(struct SNAME *_bitset_, size_t bit_index); \
bool PFX##_clear_range(struct SNAME *_bitset_, size_t from, size_t to); \
bool PFX##_flip(struct SNAME *_bitset_, size_t bit_index); \
bool PFX##_flip_range(struct SNAME *_bitset_, size_t from, size_t to); \
bool PFX##_put(struct SNAME *_bitset_, size_t bit_index, bool state); \
bool PFX##_put_range(struct SNAME *_bitset_, size_t from, size_t to, \
bool state); \
bool PFX##_set_all(struct SNAME *_bitset_); \
bool PFX##_clear_all(struct SNAME *_bitset_); \
bool PFX##_flip_all(struct SNAME *_bitset_); \
/* Element Access */ \
bool PFX##_get(struct SNAME *_bitset_, size_t bit_index); \
/* Collection State */ \
/* Collection Utility */ \
bool PFX##_resize(struct SNAME *_bitset_, size_t n_bits); \
\
/* Iterator Functions */ \
/* Iterator Initialization */ \
/* Iterator State */ \
/* Iterator Movement */ \
/* Iterator Access */ \
\
/* Utility Methods */ \
/* Translates a bit index to a word index */ \
static inline size_t PFX##_bit_to_index(size_t idx) \
{ \
/* Calculate how many shifts based on the size of cmc_bitset_word */ \
static const size_t shift = \
((sizeof(cmc_bitset_word) * 8) >> 6) > 0 \
? 6 \
: ((sizeof(cmc_bitset_word) * 8) >> 5) > 0 \
? 5 \
: ((sizeof(cmc_bitset_word) * 8) >> 4) > 0 ? 4 : 3; \
\
return idx >> shift; \
}
/* -------------------------------------------------------------------------
* Source
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_BITSET_SOURCE(PFX, SNAME) \
\
/* Implementation Detail Functions */ \
bool PFX##_impl_resize(struct SNAME *_bitset_, size_t n_bits, \
bool do_resize); \
\
struct SNAME *PFX##_new(size_t n_bits) \
{ \
return PFX##_new_custom(n_bits, NULL, NULL); \
} \
\
struct SNAME *PFX##_new_custom(size_t n_bits, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (n_bits < 1) \
return NULL; \
\
if (!alloc) \
alloc = &cmc_alloc_node_default; \
\
size_t capacity = PFX##_bit_to_index(n_bits - 1) + 1; \
\
struct SNAME *_bitset_ = alloc->malloc(sizeof(struct SNAME)); \
\
if (!_bitset_) \
return NULL; \
\
_bitset_->buffer = alloc->calloc(capacity, sizeof(cmc_bitset_word)); \
\
if (!_bitset_->buffer) \
{ \
alloc->free(_bitset_); \
return NULL; \
} \
\
_bitset_->capacity = capacity; \
_bitset_->flag = cmc_flags.OK; \
_bitset_->alloc = alloc; \
_bitset_->callbacks = callbacks; \
\
return _bitset_; \
} \
\
struct SNAME PFX##_init(size_t n_bits) \
{ \
return PFX##_init_custom(n_bits, NULL, NULL); \
} \
\
struct SNAME PFX##_init_custom(size_t n_bits, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
struct SNAME _bitset_ = { 0 }; \
\
if (n_bits < 1) \
return _bitset_; \
\
if (!alloc) \
alloc = &cmc_alloc_node_default; \
\
size_t capacity = PFX##_bit_to_index(n_bits - 1) + 1; \
\
_bitset_.buffer = alloc->calloc(capacity, sizeof(cmc_bitset_word)); \
\
if (!_bitset_.buffer) \
return _bitset_; \
\
_bitset_.capacity = capacity; \
_bitset_.flag = cmc_flags.OK; \
_bitset_.alloc = alloc; \
_bitset_.callbacks = callbacks; \
\
return _bitset_; \
} \
\
void PFX##_free(struct SNAME *_bitset_) \
{ \
free(_bitset_->buffer); \
free(_bitset_); \
} \
\
void PFX##_release(struct SNAME _bitset_) \
{ \
free(_bitset_.buffer); \
} \
\
void PFX##_customize(struct SNAME *_bitset_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (!alloc) \
_bitset_->alloc = &cmc_alloc_node_default; \
else \
_bitset_->alloc = alloc; \
\
_bitset_->callbacks = callbacks; \
\
_bitset_->flag = cmc_flags.OK; \
} \
\
bool PFX##_set(struct SNAME *_bitset_, size_t bit_index) \
{ \
if (!PFX##_impl_resize(_bitset_, bit_index + 1, false)) \
return false; \
\
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
size_t i = PFX##_bit_to_index(bit_index); \
\
_bitset_->buffer[i] |= ((cmc_bitset_word)1) << (bit_index % bits); \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->create) \
_bitset_->callbacks->create(); \
\
return true; \
} \
\
bool PFX##_set_range(struct SNAME *_bitset_, size_t from, size_t to) \
{ \
if (to < from) \
{ \
_bitset_->flag = cmc_flags.INVALID; \
return false; \
} \
\
if (!PFX##_impl_resize(_bitset_, to + 1, false)) \
return false; \
\
size_t start_index = PFX##_bit_to_index(from); \
size_t end_index = PFX##_bit_to_index(to); \
\
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
/* 1111 ... 1111 */ \
const cmc_bitset_word ones = ~((cmc_bitset_word)0); \
\
cmc_bitset_word shift_start = from % bits; \
cmc_bitset_word shift_end = (cmc_bitset_word)(-(to + 1)) % bits; \
\
cmc_bitset_word start_mask = ones << shift_start; \
cmc_bitset_word end_mask = ones >> shift_end; \
\
if (start_index == end_index) \
{ \
_bitset_->buffer[end_index] |= (start_mask & end_mask); \
} \
else \
{ \
_bitset_->buffer[start_index] |= start_mask; \
\
for (size_t i = start_index + 1; i < end_index; i++) \
_bitset_->buffer[i] |= ~((cmc_bitset_word)0); \
\
_bitset_->buffer[end_index] |= end_mask; \
} \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->create) \
_bitset_->callbacks->create(); \
\
return true; \
} \
\
bool PFX##_clear(struct SNAME *_bitset_, size_t bit_index) \
{ \
if (!PFX##_impl_resize(_bitset_, bit_index + 1, false)) \
return false; \
\
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
size_t i = PFX##_bit_to_index(bit_index); \
\
_bitset_->buffer[i] &= ~(((cmc_bitset_word)1) << (bit_index % bits)); \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->delete) \
_bitset_->callbacks->delete (); \
\
return true; \
} \
\
bool PFX##_clear_range(struct SNAME *_bitset_, size_t from, size_t to) \
{ \
if (to < from) \
{ \
_bitset_->flag = cmc_flags.INVALID; \
return false; \
} \
\
if (!PFX##_impl_resize(_bitset_, to + 1, false)) \
return false; \
\
size_t start_index = PFX##_bit_to_index(from); \
size_t end_index = PFX##_bit_to_index(to); \
\
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
/* 1111 ... 1111 */ \
const cmc_bitset_word ones = ~((cmc_bitset_word)0); \
\
cmc_bitset_word shift_start = from % bits; \
cmc_bitset_word shift_end = (cmc_bitset_word)(-(to + 1)) % bits; \
\
cmc_bitset_word start_mask = ones << shift_start; \
cmc_bitset_word end_mask = ones >> shift_end; \
\
if (start_index == end_index) \
{ \
_bitset_->buffer[end_index] &= ~(start_mask & end_mask); \
} \
else \
{ \
_bitset_->buffer[start_index] &= ~start_mask; \
\
for (size_t i = start_index + 1; i < end_index; i++) \
_bitset_->buffer[i] = 0; \
\
_bitset_->buffer[end_index] &= ~end_mask; \
} \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->delete) \
_bitset_->callbacks->delete (); \
\
return true; \
} \
\
bool PFX##_flip(struct SNAME *_bitset_, size_t bit_index) \
{ \
if (!PFX##_impl_resize(_bitset_, bit_index + 1, false)) \
return false; \
\
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
size_t i = PFX##_bit_to_index(bit_index); \
\
_bitset_->buffer[i] ^= ((cmc_bitset_word)1) << (bit_index % bits); \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->update) \
_bitset_->callbacks->update(); \
\
return true; \
} \
\
bool PFX##_flip_range(struct SNAME *_bitset_, size_t from, size_t to) \
{ \
if (to < from) \
{ \
_bitset_->flag = cmc_flags.INVALID; \
return false; \
} \
\
if (!PFX##_impl_resize(_bitset_, to + 1, false)) \
return false; \
\
size_t start_index = PFX##_bit_to_index(from); \
size_t end_index = PFX##_bit_to_index(to); \
\
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
/* 1111 ... 1111 */ \
const cmc_bitset_word ones = ~((cmc_bitset_word)0); \
\
cmc_bitset_word shift_start = from % bits; \
cmc_bitset_word shift_end = (cmc_bitset_word)(-(to + 1)) % bits; \
\
cmc_bitset_word start_mask = ones << shift_start; \
cmc_bitset_word end_mask = ones >> shift_end; \
\
if (start_index == end_index) \
{ \
_bitset_->buffer[end_index] ^= (start_mask & end_mask); \
} \
else \
{ \
_bitset_->buffer[start_index] ^= start_mask; \
\
for (size_t i = start_index + 1; i < end_index; i++) \
_bitset_->buffer[i] ^= ones; \
\
_bitset_->buffer[end_index] ^= end_mask; \
} \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->update) \
_bitset_->callbacks->update(); \
\
return true; \
} \
\
bool PFX##_put(struct SNAME *_bitset_, size_t bit_index, bool state) \
{ \
if (state) \
return PFX##_set(_bitset_, bit_index); \
else \
return PFX##_clear(_bitset_, bit_index); \
} \
\
bool PFX##_put_range(struct SNAME *_bitset_, size_t from, size_t to, \
bool state) \
{ \
if (state) \
return PFX##_set_range(_bitset_, from, to); \
else \
return PFX##_clear_range(_bitset_, from, to); \
} \
\
bool PFX##_set_all(struct SNAME *_bitset_) \
{ \
for (size_t i = 0; i < _bitset_->capacity; i++) \
_bitset_->buffer[i] = ~((cmc_bitset_word)0); \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->create) \
_bitset_->callbacks->create(); \
\
return true; \
} \
\
bool PFX##_clear_all(struct SNAME *_bitset_) \
{ \
for (size_t i = 0; i < _bitset_->capacity; i++) \
_bitset_->buffer[i] = 0; \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->delete) \
_bitset_->callbacks->delete (); \
\
return true; \
} \
\
bool PFX##_flip_all(struct SNAME *_bitset_) \
{ \
for (size_t i = 0; i < _bitset_->capacity; i++) \
_bitset_->buffer[i] ^= ~((cmc_bitset_word)0); \
\
_bitset_->flag = cmc_flags.OK; \
\
if (_bitset_->callbacks && _bitset_->callbacks->create) \
_bitset_->callbacks->create(); \
\
return true; \
} \
\
bool PFX##_get(struct SNAME *_bitset_, size_t bit_index) \
{ \
/* How many bits in a word */ \
const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; \
\
cmc_bitset_word w = _bitset_->buffer[PFX##_bit_to_index(bit_index)]; \
\
return w & ((cmc_bitset_word)1 << (bit_index % bits)); \
} \
\
bool PFX##_resize(struct SNAME *_bitset_, size_t n_bits) \
{ \
return PFX##_impl_resize(_bitset_, n_bits, true); \
} \
\
/* When do_resize is false, then we just want to assure that the bitset */ \
/* can accommodate n_bits */ \
bool PFX##_impl_resize(struct SNAME *_bitset_, size_t n_bits, \
bool do_resize) \
{ \
if (n_bits == 0) \
{ \
_bitset_->flag = cmc_flags.INVALID; \
return false; \
} \
\
/* -1 because n_bits is 1-based and we need to pass a 0-based index */ \
/* +1 to have a 1-based result */ \
size_t words = PFX##_bit_to_index(n_bits - 1) + 1; \
\
/* Be sure we are not always shrinking when we just want to make */ \
/* sure that we have enough size for n_bits */ \
if (!do_resize && words <= _bitset_->capacity) \
return true; \
\
cmc_bitset_word *new_buffer = \
realloc(_bitset_->buffer, words * sizeof(cmc_bitset_word)); \
\
if (!new_buffer) \
{ \
_bitset_->flag = cmc_flags.ALLOC; \
return false; \
} \
\
_bitset_->buffer = new_buffer; \
\
/* Make new bits be all zeroes */ \
if (_bitset_->capacity < words) \
memset(_bitset_->buffer + _bitset_->capacity, 0, \
(words - _bitset_->capacity) * sizeof(cmc_bitset_word)); \
\
_bitset_->capacity = words; \
\
if (_bitset_->callbacks && _bitset_->callbacks->resize) \
_bitset_->callbacks->resize(); \
\
_bitset_->flag = cmc_flags.OK; \
\
return true; \
}
#endif /* CMC_BITSET_H */
+123 -107
View File
@@ -88,22 +88,16 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
/* Flags indicating errors or success */ \
int flag; \
\
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the deque */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the deque */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -145,25 +139,30 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
struct SNAME PFX##_init(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME PFX##_init_custom( \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_deque_); \
void PFX##_free(struct SNAME *_deque_); \
void PFX##_release(struct SNAME _deque_); \
/* Customization of Allocation and Callbacks */ \
void PFX##_customize(struct SNAME *_deque_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_push_front(struct SNAME *_deque_, V element); \
bool PFX##_push_back(struct SNAME *_deque_, V element); \
bool PFX##_push_front(struct SNAME *_deque_, V value); \
bool PFX##_push_back(struct SNAME *_deque_, V value); \
bool PFX##_pop_front(struct SNAME *_deque_); \
bool PFX##_pop_back(struct SNAME *_deque_); \
/* Element Access */ \
V PFX##_front(struct SNAME *_deque_); \
V PFX##_back(struct SNAME *_deque_); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_deque_, V element); \
bool PFX##_contains(struct SNAME *_deque_, V value); \
bool PFX##_empty(struct SNAME *_deque_); \
bool PFX##_full(struct SNAME *_deque_); \
size_t PFX##_count(struct SNAME *_deque_); \
@@ -177,17 +176,15 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
bool PFX##_print(struct SNAME *_deque_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target); \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
bool PFX##_iter_at_start(struct SNAME##_iter *iter); \
bool PFX##_iter_at_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_to_start(struct SNAME##_iter *iter); \
bool PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
@@ -204,48 +201,15 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
#define CMC_GENERATE_DEQUE_SOURCE(PFX, SNAME, V) \
\
/* Implementation Detail Functions */ \
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_deque_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_deque_); \
/* None */ \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
if (capacity < 1) \
return NULL; \
\
if (!f_val) \
return NULL; \
\
struct SNAME *_deque_ = alloc->malloc(sizeof(struct SNAME)); \
\
if (!_deque_) \
return NULL; \
\
_deque_->buffer = alloc->calloc(capacity, sizeof(V)); \
\
if (!_deque_->buffer) \
{ \
alloc->free(_deque_); \
return NULL; \
} \
\
_deque_->capacity = capacity; \
_deque_->count = 0; \
_deque_->front = 0; \
_deque_->back = 0; \
_deque_->flag = cmc_flags.OK; \
_deque_->f_val = f_val; \
_deque_->alloc = alloc; \
_deque_->callbacks = NULL; \
_deque_->it_start = PFX##_impl_it_start; \
_deque_->it_end = PFX##_impl_it_end; \
\
return _deque_; \
return PFX##_new_custom(capacity, f_val, NULL, NULL); \
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
@@ -278,8 +242,43 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
_deque_->f_val = f_val; \
_deque_->alloc = alloc; \
_deque_->callbacks = callbacks; \
_deque_->it_start = PFX##_impl_it_start; \
_deque_->it_end = PFX##_impl_it_end; \
\
return _deque_; \
} \
\
struct SNAME PFX##_init(size_t capacity, struct SNAME##_fval *f_val) \
{ \
return PFX##_init_custom(capacity, f_val, NULL, NULL); \
} \
\
struct SNAME PFX##_init_custom( \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
struct SNAME _deque_ = { 0 }; \
\
if (capacity < 1) \
return _deque_; \
\
if (!f_val) \
return _deque_; \
\
if (!alloc) \
alloc = &cmc_alloc_node_default; \
\
_deque_.buffer = alloc->calloc(capacity, sizeof(V)); \
\
if (!_deque_.buffer) \
return _deque_; \
\
_deque_.capacity = capacity; \
_deque_.count = 0; \
_deque_.front = 0; \
_deque_.back = 0; \
_deque_.flag = cmc_flags.OK; \
_deque_.f_val = f_val; \
_deque_.alloc = alloc; \
_deque_.callbacks = callbacks; \
\
return _deque_; \
} \
@@ -321,6 +320,21 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
_deque_->alloc->free(_deque_); \
} \
\
void PFX##_release(struct SNAME _deque_) \
{ \
if (_deque_.f_val->free) \
{ \
for (size_t i = _deque_.front, j = 0; j < _deque_.count; j++) \
{ \
_deque_.f_val->free(_deque_.buffer[i]); \
\
i = (i + 1) % _deque_.capacity; \
} \
} \
\
_deque_.alloc->free(_deque_.buffer); \
} \
\
void PFX##_customize(struct SNAME *_deque_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
@@ -334,7 +348,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
_deque_->flag = cmc_flags.OK; \
} \
\
bool PFX##_push_front(struct SNAME *_deque_, V element) \
bool PFX##_push_front(struct SNAME *_deque_, V value) \
{ \
if (PFX##_full(_deque_)) \
{ \
@@ -345,7 +359,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
_deque_->front = (_deque_->front == 0) ? _deque_->capacity - 1 \
: _deque_->front - 1; \
\
_deque_->buffer[_deque_->front] = element; \
_deque_->buffer[_deque_->front] = value; \
\
_deque_->count++; \
_deque_->flag = cmc_flags.OK; \
@@ -356,7 +370,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
return true; \
} \
\
bool PFX##_push_back(struct SNAME *_deque_, V element) \
bool PFX##_push_back(struct SNAME *_deque_, V value) \
{ \
if (PFX##_full(_deque_)) \
{ \
@@ -364,7 +378,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
return false; \
} \
\
_deque_->buffer[_deque_->back] = element; \
_deque_->buffer[_deque_->back] = value; \
\
_deque_->back = \
(_deque_->back == _deque_->capacity - 1) ? 0 : _deque_->back + 1; \
@@ -456,7 +470,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
: _deque_->back - 1]; \
} \
\
bool PFX##_contains(struct SNAME *_deque_, V element) \
bool PFX##_contains(struct SNAME *_deque_, V value) \
{ \
_deque_->flag = cmc_flags.OK; \
\
@@ -464,7 +478,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
\
for (size_t i = _deque_->front, j = 0; j < _deque_->count; j++) \
{ \
if (_deque_->f_val->cmp(_deque_->buffer[i], element) == 0) \
if (_deque_->f_val->cmp(_deque_->buffer[i], value) == 0) \
{ \
result = true; \
break; \
@@ -636,44 +650,57 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
return true; \
} \
\
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target) \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target) \
{ \
struct SNAME##_iter *iter = \
target->alloc->malloc(sizeof(struct SNAME##_iter)); \
struct SNAME##_iter iter; \
\
if (!iter) \
return NULL; \
\
PFX##_iter_init(iter, target); \
iter.target = target; \
iter.cursor = target->front; \
iter.index = 0; \
iter.start = true; \
iter.end = PFX##_empty(target); \
\
return iter; \
} \
\
void PFX##_iter_free(struct SNAME##_iter *iter) \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target) \
{ \
iter->target->alloc->free(iter); \
struct SNAME##_iter iter; \
\
iter.target = target; \
\
if (!PFX##_empty(target)) \
{ \
if (iter.target->back == 0) \
iter.cursor = iter.target->capacity - 1; \
else \
iter.cursor = iter.target->back - 1; \
\
iter.index = iter.target->count - 1; \
} \
else \
{ \
iter.cursor = 0; \
iter.index = 0; \
} \
\
iter.start = PFX##_empty(target); \
iter.end = true; \
\
return iter; \
} \
\
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target) \
{ \
iter->target = target; \
iter->cursor = target->front; \
iter->index = 0; \
iter->start = true; \
iter->end = PFX##_empty(target); \
} \
\
bool PFX##_iter_start(struct SNAME##_iter *iter) \
bool PFX##_iter_at_start(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->start; \
} \
\
bool PFX##_iter_end(struct SNAME##_iter *iter) \
bool PFX##_iter_at_end(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->end; \
} \
\
void PFX##_iter_to_start(struct SNAME##_iter *iter) \
bool PFX##_iter_to_start(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -681,10 +708,14 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
iter->index = 0; \
iter->start = true; \
iter->end = false; \
\
return true; \
} \
\
return false; \
} \
\
void PFX##_iter_to_end(struct SNAME##_iter *iter) \
bool PFX##_iter_to_end(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -697,7 +728,11 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
\
iter->start = false; \
iter->end = true; \
\
return true; \
} \
\
return false; \
} \
\
bool PFX##_iter_next(struct SNAME##_iter *iter) \
@@ -824,25 +859,6 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
size_t PFX##_iter_index(struct SNAME##_iter *iter) \
{ \
return iter->index; \
} \
\
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_deque_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _deque_); \
\
return iter; \
} \
\
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_deque_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _deque_); \
PFX##_iter_to_end(&iter); \
\
return iter; \
}
#endif /* CMC_DEQUE_H */
+66 -46
View File
@@ -1,5 +1,5 @@
/**
* bidimap.h
* hashbidimap.h
*
* Creation Date: 26/09/2019
*
@@ -9,7 +9,7 @@
*/
/**
* BidiMap
* HashBidiMap
*
* A bidirectional map is a map that allows you to create a bijection in both
* directions between two sets of elements (K <-> V). It is possible to retrieve
@@ -23,8 +23,8 @@
* the key and the value.
*/
#ifndef CMC_BIDIMAP_H
#define CMC_BIDIMAP_H
#ifndef CMC_HASHBIDIMAP_H
#define CMC_HASHBIDIMAP_H
/* -------------------------------------------------------------------------
* Core functionalities of the C Macro Collections Library
@@ -37,37 +37,37 @@
#include "../cor/hashtable.h"
/* -------------------------------------------------------------------------
* Bidimap Specific
* HashBidimap Specific
* ------------------------------------------------------------------------- */
/* to_string format */
static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"count:%" PRIuMAX ", "
"load:%lf, "
"flag:%d, "
"f_key:%p, "
"f_val:%p, "
"alloc:%p, "
"callbacks:%p }";
static const char *cmc_string_fmt_hashbidimap = "struct %s<%s, %s> "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"count:%" PRIuMAX ", "
"load:%lf, "
"flag:%d, "
"f_key:%p, "
"f_val:%p, "
"alloc:%p, "
"callbacks:%p }";
#define CMC_GENERATE_BIDIMAP(PFX, SNAME, K, V) \
CMC_GENERATE_BIDIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_BIDIMAP_SOURCE(PFX, SNAME, K, V)
#define CMC_GENERATE_HASHBIDIMAP(PFX, SNAME, K, V) \
CMC_GENERATE_HASHBIDIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_HASHBIDIMAP_SOURCE(PFX, SNAME, K, V)
#define CMC_WRAPGEN_BIDIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_BIDIMAP_HEADER(PFX, SNAME, K, V)
#define CMC_WRAPGEN_HASHBIDIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_HASHBIDIMAP_HEADER(PFX, SNAME, K, V)
#define CMC_WRAPGEN_BIDIMAP_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_BIDIMAP_SOURCE(PFX, SNAME, K, V)
#define CMC_WRAPGEN_HASHBIDIMAP_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_HASHBIDIMAP_SOURCE(PFX, SNAME, K, V)
/* -------------------------------------------------------------------------
* Header
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_BIDIMAP_HEADER(PFX, SNAME, K, V) \
#define CMC_GENERATE_HASHBIDIMAP_HEADER(PFX, SNAME, K, V) \
\
/* BidiMap Structure */ \
/* HashBidiMap Structure */ \
struct SNAME \
{ \
/* Array 0 is K -> V and array 1 is V -> K */ \
@@ -86,10 +86,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -98,14 +98,14 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
struct cmc_callbacks *callbacks; \
\
/* Methods */ \
/* Function that returns an iterator to the start of the bidimap */ \
/* Returns an iterator to the start of the hashbidimap */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the bidimap */ \
/* Returns an iterator to the end of the hashbidimap */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
/* BidiMap Entry */ \
/* HashBidiMap Entry */ \
struct SNAME##_entry \
{ \
/* Entry Key */ \
@@ -119,7 +119,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
/* dist[1] is relative to V -> K */ \
size_t dist[2]; \
\
/* References to this node in the bidimap buffer. Used to */ \
/* References to this node in the hashbidimap buffer. Used to */ \
/* prevent searching for this node twice for update() and */ \
/* remove(). Increases memory overhead but reduces execution time */ \
/* ref[0] is relative to K -> V */ \
@@ -128,7 +128,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -150,7 +150,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -171,10 +171,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
int (*pri)(V, V); \
}; \
\
/* BidiMap Iterator */ \
/* HashBidiMap Iterator */ \
struct SNAME##_iter \
{ \
/* Target bidimap */ \
/* Target hashbidimap */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
@@ -199,11 +199,11 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
@@ -262,7 +262,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
/* -------------------------------------------------------------------------
* Source
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_BIDIMAP_SOURCE(PFX, SNAME, K, V) \
#define CMC_GENERATE_HASHBIDIMAP_SOURCE(PFX, SNAME, K, V) \
\
/* Implementation Detail Functions */ \
static struct SNAME##_entry *PFX##_impl_new_entry(struct SNAME *_map_, \
@@ -280,8 +280,8 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -327,8 +327,8 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
@@ -484,6 +484,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
return false; \
} \
\
/* The mapping val -> new_key is already true */ \
if (_map_->f_key->cmp(new_key, (*val_entry)->key) == 0) \
goto success; \
\
if (PFX##_impl_get_entry_by_key(_map_, new_key) != NULL) \
{ \
_map_->flag = cmc_flags.DUPLICATE; \
@@ -516,6 +520,8 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
return false; \
} \
\
success: \
\
_map_->flag = cmc_flags.OK; \
\
if (_map_->callbacks && _map_->callbacks->update) \
@@ -542,6 +548,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
return false; \
} \
\
/* The mapping key -> new_val is already true */ \
if (_map_->f_key->cmp(new_val, (*key_entry)->value) == 0) \
goto success; \
\
if (PFX##_impl_get_entry_by_val(_map_, new_val) != NULL) \
{ \
_map_->flag = cmc_flags.DUPLICATE; \
@@ -575,6 +585,8 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
return false; \
} \
\
success: \
\
_map_->flag = cmc_flags.OK; \
\
if (_map_->callbacks && _map_->callbacks->update) \
@@ -820,6 +832,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
\
if (!e1 || !e2) \
{ \
/* Prevent the map from freeing the data */ \
_new_map_->f_key = &(struct SNAME##_fkey){ NULL }; \
_new_map_->f_val = &(struct SNAME##_fval){ NULL }; \
\
_map_->alloc->free(_new_map_->buffer); \
_map_->alloc->free(_new_map_); \
\
@@ -834,6 +850,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
\
if (_map_->count != _new_map_->count) \
{ \
/* Prevent the map from freeing the data */ \
_new_map_->f_key = &(struct SNAME##_fkey){ NULL }; \
_new_map_->f_val = &(struct SNAME##_fval){ NULL }; \
\
_map_->alloc->free(_new_map_->buffer); \
_map_->alloc->free(_new_map_); \
\
@@ -953,7 +973,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
struct cmc_string str; \
struct SNAME *m_ = _map_; \
\
int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_bidimap, \
int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_hashbidimap, \
#SNAME, #K, #V, m_, m_->buffer, m_->capacity, \
m_->count, m_->load, m_->flag, m_->f_key, m_->f_val, \
m_->alloc, m_->callbacks); \
@@ -1419,4 +1439,4 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
return iter; \
}
#endif /* CMC_BIDIMAP_H */
#endif /* CMC_HASHBIDIMAP_H */
+171 -132
View File
@@ -79,22 +79,16 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the hashmap */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the hashmap */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
/* Hashmap Entry */ \
@@ -115,7 +109,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -137,7 +131,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -186,14 +180,22 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
struct SNAME PFX##_init(size_t capacity, double load, \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME PFX##_init_custom( \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
void PFX##_release(struct SNAME _map_); \
/* Customization of Allocation and Callbacks */ \
void PFX##_customize(struct SNAME *_map_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
@@ -222,17 +224,15 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
bool PFX##_print(struct SNAME *_map_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target); \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
bool PFX##_iter_at_start(struct SNAME##_iter *iter); \
bool PFX##_iter_at_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_to_start(struct SNAME##_iter *iter); \
bool PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
@@ -253,58 +253,17 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
static struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_map_, \
K key); \
static size_t PFX##_impl_calculate_size(size_t required); \
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_map_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
if (capacity == 0 || load <= 0 || load >= 1) \
return NULL; \
\
/* Prevent integer overflow */ \
if (capacity >= UINTMAX_MAX * load) \
return NULL; \
\
if (!f_key || !f_val) \
return NULL; \
\
size_t real_capacity = PFX##_impl_calculate_size(capacity / load); \
\
struct SNAME *_map_ = alloc->malloc(sizeof(struct SNAME)); \
\
if (!_map_) \
return NULL; \
\
_map_->buffer = \
alloc->calloc(real_capacity, sizeof(struct SNAME##_entry)); \
\
if (!_map_->buffer) \
{ \
alloc->free(_map_); \
return NULL; \
} \
\
_map_->count = 0; \
_map_->capacity = real_capacity; \
_map_->load = load; \
_map_->flag = cmc_flags.OK; \
_map_->f_key = f_key; \
_map_->f_val = f_val; \
_map_->alloc = alloc; \
_map_->callbacks = NULL; \
_map_->it_start = PFX##_impl_it_start; \
_map_->it_end = PFX##_impl_it_end; \
\
return _map_; \
return PFX##_new_custom(capacity, load, f_key, f_val, NULL, NULL); \
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
@@ -344,8 +303,52 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
_map_->f_val = f_val; \
_map_->alloc = alloc; \
_map_->callbacks = callbacks; \
_map_->it_start = PFX##_impl_it_start; \
_map_->it_end = PFX##_impl_it_end; \
\
return _map_; \
} \
struct SNAME PFX##_init(size_t capacity, double load, \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
return PFX##_init_custom(capacity, load, f_key, f_val, NULL, NULL); \
} \
\
struct SNAME PFX##_init_custom( \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
struct SNAME _map_ = { 0 }; \
\
if (capacity == 0 || load <= 0 || load >= 1) \
return _map_; \
\
/* Prevent integer overflow */ \
if (capacity >= UINTMAX_MAX * load) \
return _map_; \
\
if (!f_key || !f_val) \
return _map_; \
\
size_t real_capacity = PFX##_impl_calculate_size(capacity / load); \
\
if (!alloc) \
alloc = &cmc_alloc_node_default; \
\
_map_.buffer = \
alloc->calloc(real_capacity, sizeof(struct SNAME##_entry)); \
\
if (!_map_.buffer) \
return _map_; \
\
_map_.count = 0; \
_map_.capacity = real_capacity; \
_map_.load = load; \
_map_.flag = cmc_flags.OK; \
_map_.f_key = f_key; \
_map_.f_val = f_val; \
_map_.alloc = alloc; \
_map_.callbacks = callbacks; \
\
return _map_; \
} \
@@ -397,6 +400,27 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
_map_->alloc->free(_map_); \
} \
\
void PFX##_release(struct SNAME _map_) \
{ \
if (_map_.f_key->free || _map_.f_val->free) \
{ \
for (size_t i = 0; i < _map_.capacity; i++) \
{ \
struct SNAME##_entry *entry = &(_map_.buffer[i]); \
\
if (entry->state == CMC_ES_FILLED) \
{ \
if (_map_.f_key->free) \
_map_.f_key->free(entry->key); \
if (_map_.f_val->free) \
_map_.f_val->free(entry->value); \
} \
} \
} \
\
_map_.alloc->free(_map_.buffer); \
} \
\
void PFX##_customize(struct SNAME *_map_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
@@ -550,8 +574,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
return false; \
} \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _map_); \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
K max_key = PFX##_iter_key(&iter); \
V max_val = PFX##_iter_value(&iter); \
@@ -559,7 +582,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
PFX##_iter_next(&iter); \
\
/* TODO Turn this into a normal loop */ \
for (; !PFX##_iter_end(&iter); PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K iter_key = PFX##_iter_key(&iter); \
V iter_val = PFX##_iter_value(&iter); \
@@ -590,8 +613,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
return false; \
} \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _map_); \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
K min_key = PFX##_iter_key(&iter); \
V min_val = PFX##_iter_value(&iter); \
@@ -599,7 +621,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
PFX##_iter_next(&iter); \
\
/* TODO Turn this into a normal loop */ \
for (; !PFX##_iter_end(&iter); PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K iter_key = PFX##_iter_key(&iter); \
V iter_val = PFX##_iter_value(&iter); \
@@ -750,11 +772,10 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
return false; \
} \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
/* TODO turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _map_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K key = PFX##_iter_key(&iter); \
V value = PFX##_iter_value(&iter); \
@@ -779,6 +800,10 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
_map_->capacity = _new_map_->capacity; \
_new_map_->capacity = tmp_c; \
\
/* Prevent the map from freeing the data */ \
_new_map_->f_key = &(struct SNAME##_fkey){ NULL }; \
_new_map_->f_val = &(struct SNAME##_fval){ NULL }; \
\
PFX##_free(_new_map_); \
\
success: \
@@ -850,12 +875,10 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
if (_map1_->count != _map2_->count) \
return false; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _map1_); \
struct SNAME##_iter iter = PFX##_iter_start(_map1_); \
\
/* TODO optimize this loop */ \
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
struct SNAME##_entry *entry = \
PFX##_impl_get_entry(_map2_, PFX##_iter_key(&iter)); \
@@ -901,31 +924,17 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
return true; \
} \
\
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target) \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target) \
{ \
struct SNAME##_iter *iter = \
target->alloc->malloc(sizeof(struct SNAME##_iter)); \
struct SNAME##_iter iter; \
\
if (!iter) \
return NULL; \
\
PFX##_iter_init(iter, target); \
\
return iter; \
} \
\
void PFX##_iter_free(struct SNAME##_iter *iter) \
{ \
iter->target->alloc->free(iter); \
} \
\
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target) \
{ \
memset(iter, 0, sizeof(struct SNAME##_iter)); \
\
iter->target = target; \
iter->start = true; \
iter->end = PFX##_empty(target); \
iter.target = target; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = true; \
iter.end = PFX##_empty(target); \
\
if (!PFX##_empty(target)) \
{ \
@@ -933,35 +942,76 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
{ \
if (target->buffer[i].state == CMC_ES_FILLED) \
{ \
iter->first = i; \
iter.first = i; \
break; \
} \
} \
\
iter->cursor = iter->first; \
iter.cursor = iter.first; \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1].state == CMC_ES_FILLED) \
{ \
iter->last = i - 1; \
iter.last = i - 1; \
break; \
} \
} \
} \
\
return iter; \
} \
\
bool PFX##_iter_start(struct SNAME##_iter *iter) \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target) \
{ \
struct SNAME##_iter iter; \
\
iter.target = target; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = PFX##_empty(target); \
iter.end = true; \
\
if (!PFX##_empty(target)) \
{ \
for (size_t i = 0; i < target->capacity; i++) \
{ \
if (target->buffer[i].state == CMC_ES_FILLED) \
{ \
iter.first = i; \
break; \
} \
} \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1].state == CMC_ES_FILLED) \
{ \
iter.last = i - 1; \
break; \
} \
} \
\
iter.cursor = iter.last; \
iter.index = target->count - 1; \
} \
\
return iter; \
} \
\
bool PFX##_iter_at_start(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->start; \
} \
\
bool PFX##_iter_end(struct SNAME##_iter *iter) \
bool PFX##_iter_at_end(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->end; \
} \
\
void PFX##_iter_to_start(struct SNAME##_iter *iter) \
bool PFX##_iter_to_start(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -969,10 +1019,14 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
iter->index = 0; \
iter->start = true; \
iter->end = PFX##_empty(iter->target); \
\
return true; \
} \
\
return false; \
} \
\
void PFX##_iter_to_end(struct SNAME##_iter *iter) \
bool PFX##_iter_to_end(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -980,7 +1034,11 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
iter->index = iter->target->count - 1; \
iter->start = PFX##_empty(iter->target); \
iter->end = true; \
\
return true; \
} \
\
return false; \
} \
\
bool PFX##_iter_next(struct SNAME##_iter *iter) \
@@ -1161,25 +1219,6 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
i++; \
\
return cmc_hashtable_primes[i]; \
} \
\
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_map_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _map_); \
\
return iter; \
} \
\
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _map_); \
PFX##_iter_to_end(&iter); \
\
return iter; \
}
#endif /* CMC_HASHMAP_H */
+141 -138
View File
@@ -1,5 +1,5 @@
/**
* multimap.h
* hashmultimap.h
*
* Creation Date: 26/04/2019
*
@@ -9,19 +9,20 @@
*/
/**
* MultiMap
* HashMultiMap
*
* The MultiMap is a Map that allows for multiple keys. This is a data structure
* that has a very narrow usage. A Map (either TreeMap or HashMap) can also work
* like a MultiMap if a certain key is mapped to another collection.
* The HashMultiMap is a Map that allows for multiple keys. This is a data
* structure that has a very narrow usage. A Map (either TreeMap or HashMap) can
* also work like a HashMultiMap if a certain key is mapped to another
* collection.
*
* Map<K = int, V = List<int>> maps an integer to a list of integer.
* MultiMap<K = int, V = int> maps many integer keys to integer values.
* HashMultiMap<K = int, V = int> maps many integer keys to integer values.
*
* The difference is that in a MultiMap you can store keys that are the same but
* might be different instances of the same value. This is also relevant if your
* data type is more complex like a struct where its ID is the same but some
* other members of this data type are different.
* The difference is that in a HashMultiMap you can store keys that are the same
* but might be different instances of the same value. This is also relevant if
* your data type is more complex like a struct where its ID is the same but
* some other members of this data type are different.
*
* Implementation
*
@@ -40,8 +41,8 @@
* the first key added will be the first to be removed.
*/
#ifndef CMC_MULTIMAP_H
#define CMC_MULTIMAP_H
#ifndef CMC_HASHMULTIMAP_H
#define CMC_HASHMULTIMAP_H
/* -------------------------------------------------------------------------
* Core functionalities of the C Macro Collections Library
@@ -54,37 +55,37 @@
#include "../cor/hashtable.h"
/* -------------------------------------------------------------------------
* MultiMap specific
* HashMultiMap specific
* ------------------------------------------------------------------------- */
/* to_string format */
static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"count:%" PRIuMAX ", "
"load:%lf, "
"flag:%d, "
"f_key:%p, "
"f_val:%p, "
"alloc:%p, "
"callbacks:%p }";
static const char *cmc_string_fmt_hashmultimap = "struct %s<%s, %s> "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"count:%" PRIuMAX ", "
"load:%lf, "
"flag:%d, "
"f_key:%p, "
"f_val:%p, "
"alloc:%p, "
"callbacks:%p }";
#define CMC_GENERATE_MULTIMAP(PFX, SNAME, K, V) \
CMC_GENERATE_MULTIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_MULTIMAP_SOURCE(PFX, SNAME, K, V)
#define CMC_GENERATE_HASHMULTIMAP(PFX, SNAME, K, V) \
CMC_GENERATE_HASHMULTIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_HASHMULTIMAP_SOURCE(PFX, SNAME, K, V)
#define CMC_WRAPGEN_MULTIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_MULTIMAP_HEADER(PFX, SNAME, K, V)
#define CMC_WRAPGEN_HASHMULTIMAP_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_HASHMULTIMAP_HEADER(PFX, SNAME, K, V)
#define CMC_WRAPGEN_MULTIMAP_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_MULTIMAP_SOURCE(PFX, SNAME, K, V)
#define CMC_WRAPGEN_HASHMULTIMAP_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_HASHMULTIMAP_SOURCE(PFX, SNAME, K, V)
/* -------------------------------------------------------------------------
* Header
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_MULTIMAP_HEADER(PFX, SNAME, K, V) \
#define CMC_GENERATE_HASHMULTIMAP_HEADER(PFX, SNAME, K, V) \
\
/* Multimap Structure */ \
/* HashMultimap Structure */ \
struct SNAME \
{ \
/* Array of linked list to entries */ \
@@ -103,25 +104,19 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the multimap */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the multimap */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
/* Multimap Entry */ \
/* HashMultimap Entry */ \
struct SNAME##_entry \
{ \
/* Entry Key */ \
@@ -138,7 +133,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -160,7 +155,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -183,7 +178,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
\
struct SNAME##_iter \
{ \
/* Target multimap */ \
/* Target hashmultimap */ \
struct SNAME *target; \
\
/* Current entry */ \
@@ -211,11 +206,11 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
@@ -251,17 +246,15 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
bool PFX##_print(struct SNAME *_map_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target); \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
bool PFX##_iter_at_start(struct SNAME##_iter *iter); \
bool PFX##_iter_at_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_to_start(struct SNAME##_iter *iter); \
bool PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
@@ -276,7 +269,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
/* -------------------------------------------------------------------------
* Source
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_MULTIMAP_SOURCE(PFX, SNAME, K, V) \
#define CMC_GENERATE_HASHMULTIMAP_SOURCE(PFX, SNAME, K, V) \
\
/* Implementation Detail Functions */ \
struct SNAME##_entry *PFX##_impl_new_entry(struct SNAME *_map_, K key, \
@@ -284,12 +277,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_map_, K key); \
size_t PFX##_impl_key_count(struct SNAME *_map_, K key); \
size_t PFX##_impl_calculate_size(size_t required); \
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_map_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -327,15 +318,13 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
_map_->f_val = f_val; \
_map_->alloc = alloc; \
_map_->callbacks = NULL; \
_map_->it_end = PFX##_impl_it_end; \
_map_->it_start = PFX##_impl_it_start; \
\
return _map_; \
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0) \
@@ -375,8 +364,6 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
_map_->f_val = f_val; \
_map_->alloc = alloc; \
_map_->callbacks = callbacks; \
_map_->it_start = PFX##_impl_it_start; \
_map_->it_end = PFX##_impl_it_end; \
\
return _map_; \
} \
@@ -784,11 +771,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
K max_key; \
V max_val; \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
/* TODO Turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _map_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K result_key = PFX##_iter_key(&iter); \
V result_value = PFX##_iter_value(&iter); \
@@ -830,11 +816,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
K min_key; \
V min_val; \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
/* TODO Turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _map_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K result_key = PFX##_iter_key(&iter); \
V result_value = PFX##_iter_value(&iter); \
@@ -998,11 +983,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
return false; \
} \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
/* TODO Turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _map_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K key = PFX##_iter_key(&iter); \
V value = PFX##_iter_value(&iter); \
@@ -1027,6 +1011,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
_map_->capacity = _new_map_->capacity; \
_new_map_->capacity = tmp_c; \
\
/* Prevent the map from freeing the data */ \
_new_map_->f_key = &(struct SNAME##_fkey){ NULL }; \
_new_map_->f_val = &(struct SNAME##_fval){ NULL }; \
\
PFX##_free(_new_map_); \
\
success: \
@@ -1050,14 +1038,12 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
return NULL; \
} \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _map_); \
struct SNAME##_iter iter = PFX##_iter_start(_map_); \
\
if (!PFX##_empty(_map_)) \
{ \
/* TODO Turn this into a normal loop */ \
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K key = PFX##_iter_key(&iter); \
V value = PFX##_iter_value(&iter); \
@@ -1086,12 +1072,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
if (_map1_->count != _map2_->count) \
return false; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _map1_); \
struct SNAME##_iter iter = PFX##_iter_start(_map1_); \
\
/* TODO Turn this into a normal loop */ \
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
K key = PFX##_iter_key(&iter); \
\
@@ -1108,7 +1092,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
struct cmc_string str; \
struct SNAME *m_ = _map_; \
\
int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_multimap, \
int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_hashmultimap, \
#SNAME, #K, #V, m_, m_->buffer, m_->capacity, \
m_->count, m_->load, m_->flag, m_->f_key, m_->f_val, \
m_->alloc, m_->callbacks); \
@@ -1135,31 +1119,18 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
return true; \
} \
\
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target) \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target) \
{ \
struct SNAME##_iter *iter = \
target->alloc->malloc(sizeof(struct SNAME##_iter)); \
struct SNAME##_iter iter; \
\
if (!iter) \
return NULL; \
\
PFX##_iter_init(iter, target); \
\
return iter; \
} \
\
void PFX##_iter_free(struct SNAME##_iter *iter) \
{ \
iter->target->alloc->free(iter); \
} \
\
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target) \
{ \
memset(iter, 0, sizeof(struct SNAME##_iter)); \
\
iter->target = target; \
iter->start = true; \
iter->end = PFX##_empty(target); \
iter.target = target; \
iter.curr_entry = NULL; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = true; \
iter.end = PFX##_empty(target); \
\
if (!PFX##_empty(target)) \
{ \
@@ -1167,36 +1138,79 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
{ \
if (target->buffer[i][0] != NULL) \
{ \
iter->curr_entry = target->buffer[i][0]; \
iter->first = i; \
iter.curr_entry = target->buffer[i][0]; \
iter.first = i; \
break; \
} \
} \
\
iter->cursor = iter->first; \
iter.cursor = iter.first; \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1][0] != NULL) \
if (target->buffer[i - 1][1] != NULL) \
{ \
iter->last = i - 1; \
iter.last = i - 1; \
break; \
} \
} \
} \
\
return iter; \
} \
\
bool PFX##_iter_start(struct SNAME##_iter *iter) \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target) \
{ \
struct SNAME##_iter iter; \
\
iter.target = target; \
iter.curr_entry = NULL; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = PFX##_empty(target); \
iter.end = true; \
\
if (!PFX##_empty(target)) \
{ \
for (size_t i = 0; i < target->capacity; i++) \
{ \
if (target->buffer[i][0] != NULL) \
{ \
iter.first = i; \
break; \
} \
} \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1][1] != NULL) \
{ \
iter.curr_entry = target->buffer[i - 1][1]; \
iter.last = i - 1; \
break; \
} \
} \
\
iter.cursor = iter.last; \
iter.index = target->count - 1; \
} \
\
return iter; \
} \
\
bool PFX##_iter_at_start(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->start; \
} \
\
bool PFX##_iter_end(struct SNAME##_iter *iter) \
bool PFX##_iter_at_end(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->end; \
} \
\
void PFX##_iter_to_start(struct SNAME##_iter *iter) \
bool PFX##_iter_to_start(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -1205,10 +1219,14 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
iter->start = true; \
iter->end = PFX##_empty(iter->target); \
iter->curr_entry = iter->target->buffer[iter->first][0]; \
\
return true; \
} \
\
return false; \
} \
\
void PFX##_iter_to_end(struct SNAME##_iter *iter) \
bool PFX##_iter_to_end(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -1217,7 +1235,11 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
iter->start = PFX##_empty(iter->target); \
iter->end = true; \
iter->curr_entry = iter->target->buffer[iter->last][1]; \
\
return true; \
} \
\
return false; \
} \
\
bool PFX##_iter_next(struct SNAME##_iter *iter) \
@@ -1443,25 +1465,6 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
i++; \
\
return cmc_hashtable_primes[i]; \
} \
\
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_map_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _map_); \
\
return iter; \
} \
\
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _map_); \
PFX##_iter_to_end(&iter); \
\
return iter; \
}
#endif /* CMC_MULTIMAP_H */
#endif /* CMC_HASHMULTIMAP_H */
+186 -206
View File
@@ -1,5 +1,5 @@
/**
* multiset.h
* hashmultiset.h
*
* Creation Date: 10/04/2019
*
@@ -9,17 +9,22 @@
*/
/**
* MultiSet
* HashMultiSet
*
* In mathematics, a multiset is a modification of the concept of a set that,
* unlike a set, allows for multiple instances for each of its elements. The
* positive integer number of instances, given for each element is called the
* multiplicity of this element in the multiset. A MultiSet also has a
* multiplicity of this element in the multiset. A multiSet also has a
* cardinality which equals the sum of the multiplicities of its elements.
*
* Implementation
*
* In this implementation, the values are stored in a flat hashtable and are
* mapped to their multiplicity.
*/
#ifndef CMC_MULTISET_H
#define CMC_MULTISET_H
#ifndef CMC_HASHMULTISET_H
#define CMC_HASHMULTISET_H
/* -------------------------------------------------------------------------
* Core functionalities of the C Macro Collections Library
@@ -32,37 +37,37 @@
#include "../cor/hashtable.h"
/* -------------------------------------------------------------------------
* MultiSet specific
* HashMultiSet specific
* ------------------------------------------------------------------------- */
/* to_string format */
static const char *cmc_string_fmt_multiset = "struct %s<%s> "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"count:%" PRIuMAX ", "
"cardinality:%" PRIuMAX ", "
"load:%lf, "
"flag:%d, "
"f_val:%p, "
"alloc:%p, "
"callbacks:%p }";
static const char *cmc_string_fmt_hashmultiset = "struct %s<%s> "
"at %p { "
"buffer:%p, "
"capacity:%" PRIuMAX ", "
"count:%" PRIuMAX ", "
"cardinality:%" PRIuMAX ", "
"load:%lf, "
"flag:%d, "
"f_val:%p, "
"alloc:%p, "
"callbacks:%p }";
#define CMC_GENERATE_MULTISET(PFX, SNAME, V) \
CMC_GENERATE_MULTISET_HEADER(PFX, SNAME, V) \
CMC_GENERATE_MULTISET_SOURCE(PFX, SNAME, V)
#define CMC_GENERATE_HASHMULTISET(PFX, SNAME, V) \
CMC_GENERATE_HASHMULTISET_HEADER(PFX, SNAME, V) \
CMC_GENERATE_HASHMULTISET_SOURCE(PFX, SNAME, V)
#define CMC_WRAPGEN_MULTISET_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_MULTISET_HEADER(PFX, SNAME, V)
#define CMC_WRAPGEN_HASHMULTISET_HEADER(PFX, SNAME, K, V) \
CMC_GENERATE_HASHMULTISET_HEADER(PFX, SNAME, V)
#define CMC_WRAPGEN_MULTISET_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_MULTISET_SOURCE(PFX, SNAME, V)
#define CMC_WRAPGEN_HASHMULTISET_SOURCE(PFX, SNAME, K, V) \
CMC_GENERATE_HASHMULTISET_SOURCE(PFX, SNAME, V)
/* -------------------------------------------------------------------------
* Header
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_MULTISET_HEADER(PFX, SNAME, V) \
#define CMC_GENERATE_HASHMULTISET_HEADER(PFX, SNAME, V) \
\
/* Hashset Structure */ \
/* HashMultiset Structure */ \
struct SNAME \
{ \
/* Array of Entries */ \
@@ -84,19 +89,13 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the hashset */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the hashset */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
struct SNAME##_entry \
@@ -107,8 +106,8 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
/* The element's multiplicity */ \
size_t multiplicity; \
\
/* The distance of this node to its original position, used by \
* robin-hood hashing */ \
/* The distance of this node to its original position, used by */ \
/* robin-hood hashing */ \
size_t dist; \
\
/* The sate of this node (DELETED, EMPTY, FILLED) */ \
@@ -116,7 +115,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -137,10 +136,10 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
int (*pri)(V, V); \
}; \
\
/* Hashset Iterator */ \
/* HashMultiset Iterator */ \
struct SNAME##_iter \
{ \
/* Target Hashset */ \
/* Target HashMultiset */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
@@ -165,9 +164,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_set_); \
void PFX##_free(struct SNAME *_set_); \
@@ -175,17 +174,17 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
void PFX##_customize(struct SNAME *_set_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_insert(struct SNAME *_set_, V element); \
bool PFX##_insert_many(struct SNAME *_set_, V element, size_t count); \
bool PFX##_update(struct SNAME *_set_, V element, size_t multiplicity); \
bool PFX##_remove(struct SNAME *_set_, V element); \
size_t PFX##_remove_all(struct SNAME *_set_, V element); \
bool PFX##_insert(struct SNAME *_set_, V value); \
bool PFX##_insert_many(struct SNAME *_set_, V value, size_t count); \
bool PFX##_update(struct SNAME *_set_, V value, size_t multiplicity); \
bool PFX##_remove(struct SNAME *_set_, V value); \
size_t PFX##_remove_all(struct SNAME *_set_, V value); \
/* Element Access */ \
bool PFX##_max(struct SNAME *_set_, V *value); \
bool PFX##_min(struct SNAME *_set_, V *value); \
size_t PFX##_multiplicity_of(struct SNAME *_set_, V element); \
size_t PFX##_multiplicity_of(struct SNAME *_set_, V value); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_set_, V element); \
bool PFX##_contains(struct SNAME *_set_, V value); \
bool PFX##_empty(struct SNAME *_set_); \
bool PFX##_full(struct SNAME *_set_); \
size_t PFX##_count(struct SNAME *_set_); \
@@ -216,17 +215,15 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
bool PFX##_is_disjointset(struct SNAME *_set1_, struct SNAME *_set2_); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target); \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
bool PFX##_iter_at_start(struct SNAME##_iter *iter); \
bool PFX##_iter_at_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_to_start(struct SNAME##_iter *iter); \
bool PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
@@ -240,20 +237,18 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
/* -------------------------------------------------------------------------
* Source
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_MULTISET_SOURCE(PFX, SNAME, V) \
#define CMC_GENERATE_HASHMULTISET_SOURCE(PFX, SNAME, V) \
\
/* Implementation Detail Functions */ \
static size_t PFX##_impl_multiplicity_of(struct SNAME *_set_, V element); \
static size_t PFX##_impl_multiplicity_of(struct SNAME *_set_, V value); \
static struct SNAME##_entry *PFX##_impl_insert_and_return( \
struct SNAME *_set_, V element, bool *new_node); \
struct SNAME *_set_, V value, bool *new_node); \
static struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_set_, \
V element); \
V value); \
static size_t PFX##_impl_calculate_size(size_t required); \
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_set_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -291,14 +286,12 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
_set_->f_val = f_val; \
_set_->alloc = alloc; \
_set_->callbacks = NULL; \
_set_->it_start = PFX##_impl_it_start; \
_set_->it_end = PFX##_impl_it_end; \
\
return _set_; \
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
@@ -338,8 +331,6 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
_set_->f_val = f_val; \
_set_->alloc = alloc; \
_set_->callbacks = callbacks; \
_set_->it_start = PFX##_impl_it_start; \
_set_->it_end = PFX##_impl_it_end; \
\
return _set_; \
} \
@@ -398,12 +389,12 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
_set_->flag = cmc_flags.OK; \
} \
\
bool PFX##_insert(struct SNAME *_set_, V element) \
bool PFX##_insert(struct SNAME *_set_, V value) \
{ \
bool new_node; \
\
struct SNAME##_entry *entry = \
PFX##_impl_insert_and_return(_set_, element, &new_node); \
PFX##_impl_insert_and_return(_set_, value, &new_node); \
\
if (!entry) \
{ \
@@ -423,7 +414,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return true; \
} \
\
bool PFX##_insert_many(struct SNAME *_set_, V element, size_t count) \
bool PFX##_insert_many(struct SNAME *_set_, V value, size_t count) \
{ \
if (count == 0) \
goto success; \
@@ -431,7 +422,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
bool new_node; \
\
struct SNAME##_entry *entry = \
PFX##_impl_insert_and_return(_set_, element, &new_node); \
PFX##_impl_insert_and_return(_set_, value, &new_node); \
\
if (!entry) \
{ \
@@ -456,13 +447,12 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return true; \
} \
\
bool PFX##_update(struct SNAME *_set_, V element, size_t multiplicity) \
bool PFX##_update(struct SNAME *_set_, V value, size_t multiplicity) \
{ \
if (multiplicity == 0) \
{ \
/* Effectively delete the entry */ \
struct SNAME##_entry *result = \
PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, value); \
\
if (!result) \
/* If no entry was found then its multiplicity is already 0 */ \
@@ -482,7 +472,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
bool new_node; \
\
struct SNAME##_entry *entry = \
PFX##_impl_insert_and_return(_set_, element, &new_node); \
PFX##_impl_insert_and_return(_set_, value, &new_node); \
\
if (!entry) \
return false; \
@@ -505,7 +495,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return true; \
} \
\
bool PFX##_remove(struct SNAME *_set_, V element) \
bool PFX##_remove(struct SNAME *_set_, V value) \
{ \
if (PFX##_empty(_set_)) \
{ \
@@ -513,7 +503,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, value); \
\
if (!result) \
{ \
@@ -542,7 +532,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return true; \
} \
\
size_t PFX##_remove_all(struct SNAME *_set_, V element) \
size_t PFX##_remove_all(struct SNAME *_set_, V value) \
{ \
if (PFX##_empty(_set_)) \
{ \
@@ -550,7 +540,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, value); \
\
if (!result) \
{ \
@@ -584,11 +574,10 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
} \
\
V max_val; \
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set_); \
\
/* TODO transform this into a normal loop */ \
for (PFX##_iter_init(&iter, _set_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V result = PFX##_iter_value(&iter); \
size_t index = PFX##_iter_index(&iter); \
@@ -619,11 +608,10 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
} \
\
V min_val; \
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set_); \
\
/* TODO transform this into a normal loop */ \
for (PFX##_iter_init(&iter, _set_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V result = PFX##_iter_value(&iter); \
size_t index = PFX##_iter_index(&iter); \
@@ -645,9 +633,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return true; \
} \
\
size_t PFX##_multiplicity_of(struct SNAME *_set_, V element) \
size_t PFX##_multiplicity_of(struct SNAME *_set_, V value) \
{ \
struct SNAME##_entry *entry = PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *entry = PFX##_impl_get_entry(_set_, value); \
\
_set_->flag = cmc_flags.OK; \
\
@@ -660,11 +648,11 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return entry->multiplicity; \
} \
\
bool PFX##_contains(struct SNAME *_set_, V element) \
bool PFX##_contains(struct SNAME *_set_, V value) \
{ \
_set_->flag = cmc_flags.OK; \
\
bool result = PFX##_impl_get_entry(_set_, element) != NULL; \
bool result = PFX##_impl_get_entry(_set_, value) != NULL; \
\
if (_set_->callbacks && _set_->callbacks->read) \
_set_->callbacks->read(); \
@@ -744,11 +732,10 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set_); \
\
/* TODO transform this into a normal loop */ \
for (PFX##_iter_init(&iter, _set_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
PFX##_insert_many(_new_set_, PFX##_iter_value(&iter), \
PFX##_iter_multiplicity(&iter)); \
@@ -770,6 +757,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
_set_->capacity = _new_set_->capacity; \
_new_set_->capacity = tmp_c; \
\
/* Prevent the set from freeing the data */ \
_new_set_->f_val = &(struct SNAME##_fval){ NULL }; \
\
PFX##_free(_new_set_); \
\
success: \
@@ -841,11 +831,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (_set1_->count == 0) \
return true; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _set1_); \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
struct SNAME##_entry *entry = \
PFX##_impl_get_entry(_set2_, PFX##_iter_value(&iter)); \
@@ -865,7 +853,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
struct cmc_string str; \
struct SNAME *s_ = _set_; \
\
int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_multiset, \
int n = snprintf(str.s, cmc_string_len, cmc_string_fmt_hashmultiset, \
#SNAME, #V, s_, s_->buffer, s_->capacity, s_->count, \
s_->cardinality, s_->load, s_->flag, s_->f_val, \
s_->alloc, s_->callbacks); \
@@ -899,12 +887,10 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (!_set_r_) \
return NULL; \
\
struct SNAME##_iter iter1, iter2; \
PFX##_iter_init(&iter1, _set1_); \
PFX##_iter_init(&iter2, _set2_); \
struct SNAME##_iter iter1 = PFX##_iter_start(_set1_); \
struct SNAME##_iter iter2 = PFX##_iter_start(_set2_); \
\
for (PFX##_iter_to_start(&iter1); !PFX##_iter_end(&iter1); \
PFX##_iter_next(&iter1)) \
for (; !PFX##_iter_at_end(&iter1); PFX##_iter_next(&iter1)) \
{ \
V value = PFX##_iter_value(&iter1); \
\
@@ -915,8 +901,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
PFX##_update(_set_r_, value, max_); \
} \
\
for (PFX##_iter_to_start(&iter2); !PFX##_iter_end(&iter2); \
PFX##_iter_next(&iter2)) \
for (; !PFX##_iter_at_end(&iter2); PFX##_iter_next(&iter2)) \
{ \
V value = PFX##_iter_value(&iter2); \
\
@@ -947,11 +932,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
_set1_->count < _set2_->count ? _set1_ : _set2_; \
struct SNAME *_set_B_ = _set_A_ == _set1_ ? _set2_ : _set1_; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _set_A_); \
struct SNAME##_iter iter = PFX##_iter_start(_set_A_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -977,11 +960,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (!_set_r_) \
return NULL; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _set1_); \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -1007,19 +988,16 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (!_set_r_) \
return NULL; \
\
struct SNAME##_iter iter1, iter2; \
PFX##_iter_init(&iter1, _set1_); \
PFX##_iter_init(&iter2, _set2_); \
struct SNAME##_iter iter1 = PFX##_iter_start(_set1_); \
struct SNAME##_iter iter2 = PFX##_iter_start(_set2_); \
\
for (PFX##_iter_to_start(&iter1); !PFX##_iter_end(&iter1); \
PFX##_iter_next(&iter1)) \
for (; !PFX##_iter_at_end(&iter1); PFX##_iter_next(&iter1)) \
{ \
PFX##_insert_many(_set_r_, PFX##_iter_value(&iter1), \
PFX##_iter_multiplicity(&iter1)); \
} \
\
for (PFX##_iter_to_start(&iter2); !PFX##_iter_end(&iter2); \
PFX##_iter_next(&iter2)) \
for (; !PFX##_iter_at_end(&iter2); PFX##_iter_next(&iter2)) \
{ \
PFX##_insert_many(_set_r_, PFX##_iter_value(&iter2), \
PFX##_iter_multiplicity(&iter2)); \
@@ -1040,14 +1018,10 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
\
if (!_set_r_) \
return NULL; \
struct SNAME##_iter iter1 = PFX##_iter_start(_set1_); \
struct SNAME##_iter iter2 = PFX##_iter_start(_set2_); \
\
struct SNAME##_iter iter1, iter2; \
\
PFX##_iter_init(&iter1, _set1_); \
PFX##_iter_init(&iter2, _set2_); \
\
for (PFX##_iter_to_start(&iter1); !PFX##_iter_end(&iter1); \
PFX##_iter_next(&iter1)) \
for (; !PFX##_iter_at_end(&iter1); PFX##_iter_next(&iter1)) \
{ \
V value = PFX##_iter_value(&iter1); \
\
@@ -1063,8 +1037,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
} \
} \
\
for (PFX##_iter_to_start(&iter2); !PFX##_iter_end(&iter2); \
PFX##_iter_next(&iter2)) \
for (; !PFX##_iter_at_end(&iter2); PFX##_iter_next(&iter2)) \
{ \
V value = PFX##_iter_value(&iter2); \
\
@@ -1093,12 +1066,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (PFX##_empty(_set1_)) \
return true; \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
PFX##_iter_init(&iter, _set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -1130,12 +1100,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
PFX##_iter_init(&iter, _set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -1159,12 +1126,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (PFX##_empty(_set1_)) \
return true; \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
PFX##_iter_init(&iter, _set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -1175,31 +1139,17 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return true; \
} \
\
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target) \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target) \
{ \
struct SNAME##_iter *iter = \
target->alloc->malloc(sizeof(struct SNAME##_iter)); \
struct SNAME##_iter iter; \
\
if (!iter) \
return NULL; \
\
PFX##_iter_init(iter, target); \
\
return iter; \
} \
\
void PFX##_iter_free(struct SNAME##_iter *iter) \
{ \
iter->target->alloc->free(iter); \
} \
\
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target) \
{ \
memset(iter, 0, sizeof(struct SNAME##_iter)); \
\
iter->target = target; \
iter->start = true; \
iter->end = PFX##_empty(target); \
iter.target = target; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = true; \
iter.end = PFX##_empty(target); \
\
if (!PFX##_empty(target)) \
{ \
@@ -1207,35 +1157,76 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
{ \
if (target->buffer[i].state == CMC_ES_FILLED) \
{ \
iter->first = i; \
iter.first = i; \
break; \
} \
} \
\
iter->cursor = iter->first; \
iter.cursor = iter.first; \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1].state == CMC_ES_FILLED) \
{ \
iter->last = i - 1; \
iter.last = i - 1; \
break; \
} \
} \
} \
\
return iter; \
} \
\
bool PFX##_iter_start(struct SNAME##_iter *iter) \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target) \
{ \
struct SNAME##_iter iter; \
\
iter.target = target; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = PFX##_empty(target); \
iter.end = true; \
\
if (!PFX##_empty(target)) \
{ \
for (size_t i = 0; i < target->capacity; i++) \
{ \
if (target->buffer[i].state == CMC_ES_FILLED) \
{ \
iter.first = i; \
break; \
} \
} \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1].state == CMC_ES_FILLED) \
{ \
iter.last = i - 1; \
break; \
} \
} \
\
iter.cursor = iter.last; \
iter.index = target->count - 1; \
} \
\
return iter; \
} \
\
bool PFX##_iter_at_start(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->start; \
} \
\
bool PFX##_iter_end(struct SNAME##_iter *iter) \
bool PFX##_iter_at_end(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->end; \
} \
\
void PFX##_iter_to_start(struct SNAME##_iter *iter) \
bool PFX##_iter_to_start(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -1243,10 +1234,14 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
iter->index = 0; \
iter->start = true; \
iter->end = PFX##_empty(iter->target); \
\
return true; \
} \
\
return false; \
} \
\
void PFX##_iter_to_end(struct SNAME##_iter *iter) \
bool PFX##_iter_to_end(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -1254,7 +1249,11 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
iter->index = iter->target->count - 1; \
iter->start = PFX##_empty(iter->target); \
iter->end = true; \
\
return true; \
} \
\
return false; \
} \
\
bool PFX##_iter_next(struct SNAME##_iter *iter) \
@@ -1393,9 +1392,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return iter->index; \
} \
\
static size_t PFX##_impl_multiplicity_of(struct SNAME *_set_, V element) \
static size_t PFX##_impl_multiplicity_of(struct SNAME *_set_, V value) \
{ \
struct SNAME##_entry *entry = PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *entry = PFX##_impl_get_entry(_set_, value); \
\
if (!entry) \
return 0; \
@@ -1404,15 +1403,15 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
} \
\
static struct SNAME##_entry *PFX##_impl_insert_and_return( \
struct SNAME *_set_, V element, bool *new_node) \
struct SNAME *_set_, V value, bool *new_node) \
{ \
/* If the entry already exists simply return it as we might do */ \
/* something with it. This function only guarantees that there is */ \
/* a valid entry for a given element */ \
/* a valid entry for a given value */ \
\
*new_node = false; \
\
struct SNAME##_entry *entry = PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *entry = PFX##_impl_get_entry(_set_, value); \
\
if (entry != NULL) \
return entry; \
@@ -1425,7 +1424,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
return NULL; \
} \
\
size_t hash = _set_->f_val->hash(element); \
size_t hash = _set_->f_val->hash(value); \
size_t original_pos = hash % _set_->capacity; \
size_t pos = original_pos; \
/* Current multiplicity. Might change due to robin hood hashing */ \
@@ -1435,7 +1434,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
\
if (target->state == CMC_ES_EMPTY || target->state == CMC_ES_DELETED) \
{ \
target->value = element; \
target->value = value; \
target->multiplicity = curr_mul; \
target->dist = pos - original_pos; \
target->state = CMC_ES_FILLED; \
@@ -1450,7 +1449,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
if (target->state == CMC_ES_EMPTY || \
target->state == CMC_ES_DELETED) \
{ \
target->value = element; \
target->value = value; \
target->multiplicity = curr_mul; \
target->dist = pos - original_pos; \
target->state = CMC_ES_FILLED; \
@@ -1464,11 +1463,11 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
size_t tmp_dist = target->dist; \
size_t tmp_mul = target->multiplicity; \
\
target->value = element; \
target->value = value; \
target->dist = pos - original_pos; \
target->multiplicity = curr_mul; \
\
element = tmp; \
value = tmp; \
original_pos = pos - tmp_dist; \
curr_mul = tmp_mul; \
} \
@@ -1481,9 +1480,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
} \
\
static struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_set_, \
V element) \
V value) \
{ \
size_t hash = _set_->f_val->hash(element); \
size_t hash = _set_->f_val->hash(value); \
size_t pos = hash % _set_->capacity; \
\
struct SNAME##_entry *target = &(_set_->buffer[pos]); \
@@ -1491,7 +1490,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
while (target->state == CMC_ES_FILLED || \
target->state == CMC_ES_DELETED) \
{ \
if (_set_->f_val->cmp(target->value, element) == 0) \
if (_set_->f_val->cmp(target->value, value) == 0) \
return target; \
\
pos++; \
@@ -1514,25 +1513,6 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
i++; \
\
return cmc_hashtable_primes[i]; \
} \
\
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_set_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _set_); \
\
return iter; \
} \
\
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _set_); \
PFX##_iter_to_end(&iter); \
\
return iter; \
}
#endif /* CMC_MULTISET_H */
#endif /* CMC_HASHMULTISET_H */
+124 -142
View File
@@ -78,19 +78,13 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the hashset */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the hashset */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
struct SNAME##_entry \
@@ -107,7 +101,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -156,9 +150,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_set_); \
void PFX##_free(struct SNAME *_set_); \
@@ -166,13 +160,13 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
void PFX##_customize(struct SNAME *_set_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_insert(struct SNAME *_set_, V element); \
bool PFX##_remove(struct SNAME *_set_, V element); \
bool PFX##_insert(struct SNAME *_set_, V value); \
bool PFX##_remove(struct SNAME *_set_, V value); \
/* Element Access */ \
bool PFX##_max(struct SNAME *_set_, V *value); \
bool PFX##_min(struct SNAME *_set_, V *value); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_set_, V element); \
bool PFX##_contains(struct SNAME *_set_, V value); \
bool PFX##_empty(struct SNAME *_set_); \
bool PFX##_full(struct SNAME *_set_); \
size_t PFX##_count(struct SNAME *_set_); \
@@ -201,17 +195,15 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
bool PFX##_is_disjointset(struct SNAME *_set1_, struct SNAME *_set2_); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target); \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
bool PFX##_iter_at_start(struct SNAME##_iter *iter); \
bool PFX##_iter_at_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_to_start(struct SNAME##_iter *iter); \
bool PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
@@ -228,13 +220,13 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
\
/* Implementation Detail Functions */ \
static struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_set_, \
V element); \
V value); \
static size_t PFX##_impl_calculate_size(size_t required); \
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_set_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -271,14 +263,12 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
_set_->f_val = f_val; \
_set_->alloc = alloc; \
_set_->callbacks = NULL; \
_set_->it_start = PFX##_impl_it_start; \
_set_->it_end = PFX##_impl_it_end; \
\
return _set_; \
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
@@ -317,8 +307,6 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
_set_->f_val = f_val; \
_set_->alloc = alloc; \
_set_->callbacks = callbacks; \
_set_->it_start = PFX##_impl_it_start; \
_set_->it_end = PFX##_impl_it_end; \
\
return _set_; \
} \
@@ -377,7 +365,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
_set_->flag = cmc_flags.OK; \
} \
\
bool PFX##_insert(struct SNAME *_set_, V element) \
bool PFX##_insert(struct SNAME *_set_, V value) \
{ \
if (PFX##_full(_set_)) \
{ \
@@ -385,13 +373,13 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return false; \
} \
\
if (PFX##_impl_get_entry(_set_, element) != NULL) \
if (PFX##_impl_get_entry(_set_, value) != NULL) \
{ \
_set_->flag = cmc_flags.DUPLICATE; \
return false; \
} \
\
size_t hash = _set_->f_val->hash(element); \
size_t hash = _set_->f_val->hash(value); \
size_t original_pos = hash % _set_->capacity; \
size_t pos = original_pos; \
\
@@ -399,7 +387,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
\
if (target->state == CMC_ES_EMPTY || target->state == CMC_ES_DELETED) \
{ \
target->value = element; \
target->value = value; \
target->dist = 0; \
target->state = CMC_ES_FILLED; \
} \
@@ -413,7 +401,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
if (target->state == CMC_ES_EMPTY || \
target->state == CMC_ES_DELETED) \
{ \
target->value = element; \
target->value = value; \
target->dist = pos - original_pos; \
target->state = CMC_ES_FILLED; \
\
@@ -424,10 +412,10 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
V tmp = target->value; \
size_t tmp_dist = target->dist; \
\
target->value = element; \
target->value = value; \
target->dist = pos - original_pos; \
\
element = tmp; \
value = tmp; \
original_pos = pos - tmp_dist; \
} \
} \
@@ -442,7 +430,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return true; \
} \
\
bool PFX##_remove(struct SNAME *_set_, V element) \
bool PFX##_remove(struct SNAME *_set_, V value) \
{ \
if (PFX##_empty(_set_)) \
{ \
@@ -450,7 +438,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, element); \
struct SNAME##_entry *result = PFX##_impl_get_entry(_set_, value); \
\
if (result == NULL) \
{ \
@@ -480,11 +468,10 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
} \
\
V max_value; \
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set_); \
\
/* TODO turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _set_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V result = PFX##_iter_value(&iter); \
size_t index = PFX##_iter_index(&iter); \
@@ -515,11 +502,10 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
} \
\
V min_value; \
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set_); \
\
/* TODO turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _set_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V result = PFX##_iter_value(&iter); \
size_t index = PFX##_iter_index(&iter); \
@@ -541,11 +527,11 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return true; \
} \
\
bool PFX##_contains(struct SNAME *_set_, V element) \
bool PFX##_contains(struct SNAME *_set_, V value) \
{ \
_set_->flag = cmc_flags.OK; \
\
bool result = PFX##_impl_get_entry(_set_, element) != NULL; \
bool result = PFX##_impl_get_entry(_set_, value) != NULL; \
\
if (_set_->callbacks && _set_->callbacks->read) \
_set_->callbacks->read(); \
@@ -620,11 +606,10 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set_); \
\
/* TODO turn this into a normal loop */ \
for (PFX##_iter_init(&iter, _set_); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -649,6 +634,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
_set_->capacity = _new_set_->capacity; \
_new_set_->capacity = tmp_c; \
\
/* Prevent the set from freeing the data */ \
_new_set_->f_val = &(struct SNAME##_fval){ NULL }; \
\
PFX##_free(_new_set_); \
\
success: \
@@ -715,12 +703,10 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
if (_set1_->count == 0) \
return true; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _set1_); \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
/* TODO optimize this loop */ \
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
if (PFX##_impl_get_entry(_set2_, PFX##_iter_value(&iter)) == NULL) \
return false; \
@@ -772,19 +758,16 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return NULL; \
} \
\
struct SNAME##_iter iter1, iter2; \
PFX##_iter_init(&iter1, _set1_); \
PFX##_iter_init(&iter2, _set2_); \
struct SNAME##_iter iter1 = PFX##_iter_start(_set1_); \
struct SNAME##_iter iter2 = PFX##_iter_start(_set2_); \
\
/* TODO turn this into a normal loop and check for errors */ \
for (PFX##_iter_to_start(&iter1); !PFX##_iter_end(&iter1); \
PFX##_iter_next(&iter1)) \
for (; !PFX##_iter_at_end(&iter1); PFX##_iter_next(&iter1)) \
{ \
PFX##_insert(_set_r_, PFX##_iter_value(&iter1)); \
} \
\
for (PFX##_iter_to_start(&iter2); !PFX##_iter_end(&iter2); \
PFX##_iter_next(&iter2)) \
for (; !PFX##_iter_at_end(&iter2); PFX##_iter_next(&iter2)) \
{ \
PFX##_insert(_set_r_, PFX##_iter_value(&iter2)); \
} \
@@ -813,11 +796,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
_set1_->count < _set2_->count ? _set1_ : _set2_; \
struct SNAME *_set_B_ = _set_A_ == _set1_ ? _set2_ : _set1_; \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _set_A_); \
struct SNAME##_iter iter = PFX##_iter_start(_set_A_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -844,11 +825,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return NULL; \
} \
\
struct SNAME##_iter iter; \
PFX##_iter_init(&iter, _set1_); \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -876,13 +855,10 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return NULL; \
} \
\
struct SNAME##_iter iter1, iter2; \
struct SNAME##_iter iter1 = PFX##_iter_start(_set1_); \
struct SNAME##_iter iter2 = PFX##_iter_start(_set2_); \
\
PFX##_iter_init(&iter1, _set1_); \
PFX##_iter_init(&iter2, _set2_); \
\
for (PFX##_iter_to_start(&iter1); !PFX##_iter_end(&iter1); \
PFX##_iter_next(&iter1)) \
for (; !PFX##_iter_at_end(&iter1); PFX##_iter_next(&iter1)) \
{ \
V value = PFX##_iter_value(&iter1); \
\
@@ -890,8 +866,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
PFX##_insert(_set_r_, value); \
} \
\
for (PFX##_iter_to_start(&iter2); !PFX##_iter_end(&iter2); \
PFX##_iter_next(&iter2)) \
for (; !PFX##_iter_at_end(&iter2); PFX##_iter_next(&iter2)) \
{ \
V value = PFX##_iter_value(&iter2); \
\
@@ -921,12 +896,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
if (PFX##_empty(_set1_)) \
return true; \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
PFX##_iter_init(&iter, _set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -970,12 +942,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return false; \
} \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
PFX##_iter_init(&iter, _set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -1007,12 +976,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
if (PFX##_empty(_set1_)) \
return true; \
\
struct SNAME##_iter iter; \
struct SNAME##_iter iter = PFX##_iter_start(_set1_); \
\
PFX##_iter_init(&iter, _set1_); \
\
for (PFX##_iter_to_start(&iter); !PFX##_iter_end(&iter); \
PFX##_iter_next(&iter)) \
for (; !PFX##_iter_at_end(&iter); PFX##_iter_next(&iter)) \
{ \
V value = PFX##_iter_value(&iter); \
\
@@ -1023,31 +989,17 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
return true; \
} \
\
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target) \
struct SNAME##_iter PFX##_iter_start(struct SNAME *target) \
{ \
struct SNAME##_iter *iter = \
target->alloc->malloc(sizeof(struct SNAME##_iter)); \
struct SNAME##_iter iter; \
\
if (!iter) \
return NULL; \
\
PFX##_iter_init(iter, target); \
\
return iter; \
} \
\
void PFX##_iter_free(struct SNAME##_iter *iter) \
{ \
iter->target->alloc->free(iter); \
} \
\
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target) \
{ \
memset(iter, 0, sizeof(struct SNAME##_iter)); \
\
iter->target = target; \
iter->start = true; \
iter->end = PFX##_empty(target); \
iter.target = target; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = true; \
iter.end = PFX##_empty(target); \
\
if (!PFX##_empty(target)) \
{ \
@@ -1055,35 +1007,76 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
{ \
if (target->buffer[i].state == CMC_ES_FILLED) \
{ \
iter->first = i; \
iter.first = i; \
break; \
} \
} \
\
iter->cursor = iter->first; \
iter.cursor = iter.first; \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1].state == CMC_ES_FILLED) \
{ \
iter->last = i - 1; \
iter.last = i - 1; \
break; \
} \
} \
} \
\
return iter; \
} \
\
bool PFX##_iter_start(struct SNAME##_iter *iter) \
struct SNAME##_iter PFX##_iter_end(struct SNAME *target) \
{ \
struct SNAME##_iter iter; \
\
iter.target = target; \
iter.cursor = 0; \
iter.index = 0; \
iter.first = 0; \
iter.last = 0; \
iter.start = PFX##_empty(target); \
iter.end = true; \
\
if (!PFX##_empty(target)) \
{ \
for (size_t i = 0; i < target->capacity; i++) \
{ \
if (target->buffer[i].state == CMC_ES_FILLED) \
{ \
iter.first = i; \
break; \
} \
} \
\
for (size_t i = target->capacity; i > 0; i--) \
{ \
if (target->buffer[i - 1].state == CMC_ES_FILLED) \
{ \
iter.last = i - 1; \
break; \
} \
} \
\
iter.cursor = iter.last; \
iter.index = target->count - 1; \
} \
\
return iter; \
} \
\
bool PFX##_iter_at_start(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->start; \
} \
\
bool PFX##_iter_end(struct SNAME##_iter *iter) \
bool PFX##_iter_at_end(struct SNAME##_iter *iter) \
{ \
return PFX##_empty(iter->target) || iter->end; \
} \
\
void PFX##_iter_to_start(struct SNAME##_iter *iter) \
bool PFX##_iter_to_start(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -1091,10 +1084,14 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
iter->index = 0; \
iter->start = true; \
iter->end = PFX##_empty(iter->target); \
\
return true; \
} \
\
return false; \
} \
\
void PFX##_iter_to_end(struct SNAME##_iter *iter) \
bool PFX##_iter_to_end(struct SNAME##_iter *iter) \
{ \
if (!PFX##_empty(iter->target)) \
{ \
@@ -1102,7 +1099,11 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
iter->index = iter->target->count - 1; \
iter->start = PFX##_empty(iter->target); \
iter->end = true; \
\
return true; \
} \
\
return false; \
} \
\
bool PFX##_iter_next(struct SNAME##_iter *iter) \
@@ -1234,9 +1235,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
} \
\
static struct SNAME##_entry *PFX##_impl_get_entry(struct SNAME *_set_, \
V element) \
V value) \
{ \
size_t hash = _set_->f_val->hash(element); \
size_t hash = _set_->f_val->hash(value); \
size_t pos = hash % _set_->capacity; \
\
struct SNAME##_entry *target = &(_set_->buffer[pos]); \
@@ -1244,7 +1245,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
while (target->state == CMC_ES_FILLED || \
target->state == CMC_ES_DELETED) \
{ \
if (_set_->f_val->cmp(target->value, element) == 0) \
if (_set_->f_val->cmp(target->value, value) == 0) \
return target; \
\
pos++; \
@@ -1267,25 +1268,6 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
i++; \
\
return cmc_hashtable_primes[i]; \
} \
\
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_set_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _set_); \
\
return iter; \
} \
\
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_) \
{ \
struct SNAME##_iter iter; \
\
PFX##_iter_init(&iter, _set_); \
PFX##_iter_to_end(&iter); \
\
return iter; \
}
#endif /* CMC_HASHSET_H */
Loaded 100 of 195 files, more files were not shown because too many files have changed in this diff. Show more