Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7ee017bcd | ||
|
|
09d1cb649d | ||
|
|
4925b5fa06 | ||
|
|
3d4733fd5f | ||
|
|
dba782ccd6 | ||
|
|
3a1d244286 | ||
|
|
bd3198adf5 | ||
|
|
4e194f28ee | ||
|
|
1911415879 | ||
|
|
5740815a49 | ||
|
|
2424f0d8cd | ||
|
|
6cb2160456 | ||
|
|
61aa8b879e | ||
|
|
209d45be5d | ||
|
|
b6343b4857 | ||
|
|
f1ab010701 | ||
|
|
18a8810c4c | ||
|
|
3f97fca40e | ||
|
|
27d70cb32c | ||
|
|
cf9c684ecb | ||
|
|
6308936e65 |
No files matched your search
@@ -10,7 +10,13 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup Environment
|
||||
run: sudo apt install make valgrind gcc python
|
||||
run: sudo apt install make valgrind gcc python3.8
|
||||
- name: Versions
|
||||
run: |
|
||||
gcc --version \
|
||||
make --version \
|
||||
valgrind --version \
|
||||
python --version \
|
||||
- name: Test Suite
|
||||
run: python autogen.py -e -b -r -nf
|
||||
# - name: Valgrind Test
|
||||
|
||||
+5
-4
@@ -12,12 +12,13 @@ addons:
|
||||
- cmake
|
||||
- python3.8
|
||||
script:
|
||||
- sudo ln -s /usr/bin/gcc-9 /usr/local/bin/gcc
|
||||
- sudo ln -s /usr/bin/gcov-9 /usr/local/bin/gcov
|
||||
- sudo ln -s /usr/bin/python3.8 /usr/local/bin/python
|
||||
- sudo rm -f /usr/bin/gcc /usr/bin/gcov /usr/bin/python
|
||||
- sudo ln -s /usr/bin/gcc-9 /usr/bin/gcc
|
||||
- sudo ln -s /usr/bin/gcov-9 /usr/bin/gcov
|
||||
- sudo ln -s /usr/bin/python3.8 /usr/bin/python
|
||||
- gcc --version
|
||||
- gcov --version
|
||||
- python --version
|
||||
- python autogen.py -e -b -cv -r -nf
|
||||
- python autogen.py -e -b -cv -r -nf -nt
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
@@ -1,5 +1,9 @@
|
||||
# RELEASE.MAJOR.MINOR
|
||||
|
||||
0.25.0
|
||||
New Project Architecture - Files are no longer separated in folders, but rather prefixed by their sub-library
|
||||
Added sac_list.h
|
||||
|
||||
0.24.0
|
||||
A lot of breaking changes, with the library more modular now
|
||||
Comeback of PUBLIC and PRIVATE for the CMC sub-library
|
||||
|
||||
@@ -8,15 +8,16 @@
|
||||
|
||||
<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://github.com/LeoVen/C-Macro-Collections/stargazers"><img src="https://img.shields.io/github/stars/LeoVen/C-Macro-Collections?style=flat&color=ffa000" alt="Stars"/></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.24.0-orange.svg" alt="Version"/>
|
||||
<a href="https://github.com/LeoVen/C-Macro-Collections/releases"><img src="https://img.shields.io/badge/Version-v0.25.0-orange.svg" alt="Version"/></a>
|
||||
<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"/>
|
||||
<a href="https://github.com/LeoVen/C-Macro-Collections/actions"><img src="https://github.com/LeoVen/C-Macro-Collections/workflows/Test%20Suit/badge.svg?branch=master" alt="test_suit"/></a>
|
||||
</p>
|
||||
|
||||
## Table of Contents
|
||||
@@ -61,7 +62,7 @@ Below is a minimal example that makes use of some core functionalities. And a lo
|
||||
// needs to be generated first. Then, we can add other parts after. This macro
|
||||
// does all of that for us. The STR part will provide us with a function that
|
||||
// will be used later.
|
||||
C_MACRO_COLLECTIONS_GEN(CMC, LIST, MY_LIST_PARAMS, (STR))
|
||||
C_MACRO_COLLECTIONS_EXTENDED(CMC, LIST, MY_LIST_PARAMS, (STR))
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -137,11 +138,12 @@ The C Macro Collections library is organized into many other sub-libraries. The
|
||||
Every macro that generates code for a certain collection can be found with the following template. Some exceptions exist as certain collections don't have or can't have some features. One big example is the `UTL` library, which does not follow this pattern.
|
||||
|
||||
```
|
||||
macro_name := CMC_[ lib ]_[ collection ]_[ part ]_[ file ]
|
||||
macro_name := CMC_[ lib ]_[ collection ]_[ part ]_[ access ]_[ file ]
|
||||
|
||||
lib := CMC | COR | DEV | EXT | INT | SAC | TSC
|
||||
collection := BITSET | DEQUE | HASHBIDIMAP | ... | TREEMULTISET | TREESET
|
||||
part := CORE | ITER | INIT | ... | SETF | NODE
|
||||
access := PUBLIC | PRIVATE
|
||||
file := HEADER | SOURCE
|
||||
```
|
||||
|
||||
@@ -156,13 +158,6 @@ Every macro is suffixed by `CMC` and each section is separated by an underscore
|
||||
* __documentation__ - The markdowns used by [mdBook](https://github.com/rust-lang/mdBook) to generate the website
|
||||
* __examples__ - Examples using the C Macro Collections Library
|
||||
* __src__ - All headers part of the C Macro Collections Library
|
||||
* __cmc__ - The main C Macro Collections Library
|
||||
* __cor__ - Core includes in the C Macro Collections Library
|
||||
* __ext__ - Extensions to the CMC, SAC and TSC collections
|
||||
* __int__ - Integrations between Collections
|
||||
* __sac__ - Statically Allocated Collections
|
||||
* __tsc__ - Thread Safe Collections
|
||||
* __utl__ - Utilities like ForEach macros, logging, etc
|
||||
* __macro\_collections.h__ - Master header containing all collections and utilities
|
||||
* __tests__ - Where all tests are hosted
|
||||
|
||||
|
||||
+198
-128
@@ -1,5 +1,4 @@
|
||||
# A script that automatically generates code for code coverage, updates tests
|
||||
# and Makefiles, and creates necessary directories
|
||||
# A script for automation
|
||||
|
||||
import argparse
|
||||
import os
|
||||
@@ -12,11 +11,9 @@ from typing import List, Text
|
||||
|
||||
# Config Script Configuration
|
||||
# Directories Names for directories
|
||||
# Output Where the outputted code is to be put
|
||||
# Build Where the build objects are to be located
|
||||
# Files Names for files
|
||||
# Compiler Compiler Configurations
|
||||
# Compilation Tests, code coverage and flags
|
||||
# Macro Expansion Configuration for the code expansion
|
||||
# Macro Expansion Configuration for the code expansion
|
||||
# Collections All collections
|
||||
#
|
||||
# Variables marked as const are to not be modified
|
||||
@@ -25,10 +22,10 @@ from typing import List, Text
|
||||
|
||||
# Output directory
|
||||
# In this directory it is assumed that the following files and directories are
|
||||
# included: main.c, unt folder
|
||||
# included: main.c, codecov.c, unt folder
|
||||
OUTPUT_DIR = './tests'
|
||||
# All libraries
|
||||
ALL_LIBS = ['CMC']
|
||||
# Where the unit test files are
|
||||
UNT_DIR = f'{OUTPUT_DIR}/unt'
|
||||
# Directory mapping
|
||||
DIR_MAP = {'HEADER': 'include', 'SOURCE': 'src'}
|
||||
# File extension mapping
|
||||
@@ -39,33 +36,46 @@ BUILD_DIR = f'{OUTPUT_DIR}/build'
|
||||
INCLUDE_DIR = f"{OUTPUT_DIR}/{DIR_MAP['HEADER']}"
|
||||
# const
|
||||
SRC_DIR = f"{OUTPUT_DIR}/{DIR_MAP['SOURCE']}"
|
||||
# Where executables go
|
||||
BIN_DIR = f'{BUILD_DIR}/bin'
|
||||
# Where object files .o go
|
||||
OBJ_DIR = BUILD_DIR
|
||||
# The name of the main test executable
|
||||
TEST_EXE = f'{OUTPUT_DIR}/main.exe'
|
||||
# Where .gcov files should go
|
||||
GCOV_DIR = f'{BUILD_DIR}/gcov'
|
||||
|
||||
# Files
|
||||
# All const
|
||||
|
||||
# The name of the main test
|
||||
MAIN = 'main'
|
||||
# The name of the code coverage file
|
||||
CODECOV = 'codecov'
|
||||
# The name of the single test file
|
||||
SINGLE = 'single'
|
||||
|
||||
# Compiler
|
||||
|
||||
# Compilation
|
||||
# Compiler to be used
|
||||
CC = 'gcc'
|
||||
# Compilation Flags
|
||||
CFLAGS = ['-Wall', '-Werror']
|
||||
CFLAGS = ['-Wall', '-Werror', '-O3']
|
||||
# Link flags
|
||||
LFLAGS = []
|
||||
# Coverage Flags
|
||||
CVFLAGS = ['--coverage', '-O0']
|
||||
# gcov flags
|
||||
GCOV_FLAGS = []
|
||||
# Include to the main Library
|
||||
# Include of the main library
|
||||
# const
|
||||
INCLUDE = ['-I', './src']
|
||||
# Include to the test file headers
|
||||
# const
|
||||
TINCLUDE = ['-I', f'{INCLUDE_DIR}']
|
||||
TINCLUDE = ['-I', f'{INCLUDE_DIR}', '-I', f'{UNT_DIR}']
|
||||
# Include to code coverage
|
||||
# const
|
||||
CVINCLUDE = ['-I', INCLUDE_DIR, '-I', SRC_DIR, '-I', f'{UNT_DIR}']
|
||||
|
||||
# Macro expansion
|
||||
# Macro Expansion
|
||||
|
||||
# -E Only preprocessor
|
||||
# -P No linemarkers
|
||||
@@ -78,10 +88,33 @@ UNIQUE_FLAG = '// C_MACRO_COLLECTIONS_CODE'
|
||||
# Temporary file used to expand the macros
|
||||
TMP_FILE = './main.c'
|
||||
|
||||
|
||||
# All collections that can be used for testing
|
||||
COLLECTIONS = [
|
||||
# header, library, collection, pfx, sname, size, key, val
|
||||
{'h': '"cmc_bitset.h"', 'LIB': 'CMC', 'COLLECTION': 'BITSET', 'PFX': 'bs', 'SNAME': 'bitset', 'SIZE': '', 'K': '', 'V': '' },
|
||||
{'h': '"cmc_deque.h"', 'LIB': 'CMC', 'COLLECTION': 'DEQUE', 'PFX': 'd', 'SNAME': 'deque', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_hashbidimap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHBIDIMAP', 'PFX': 'hbm', 'SNAME': 'hashbidimap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc_hashmap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMAP', 'PFX': 'hm', 'SNAME': 'hashmap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc_hashmultimap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMULTIMAP', 'PFX': 'hmm', 'SNAME': 'hashmultimap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc_hashmultiset.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMULTISET', 'PFX': 'hms', 'SNAME': 'hashmultiset', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_hashset.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHSET', 'PFX': 'hs', 'SNAME': 'hashset', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_heap.h"', 'LIB': 'CMC', 'COLLECTION': 'HEAP', 'PFX': 'h', 'SNAME': 'heap', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_intervalheap.h"', 'LIB': 'CMC', 'COLLECTION': 'INTERVALHEAP', 'PFX': 'ih', 'SNAME': 'intervalheap', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_linkedlist.h"', 'LIB': 'CMC', 'COLLECTION': 'LINKEDLIST', 'PFX': 'll', 'SNAME': 'linkedlist', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_list.h"', 'LIB': 'CMC', 'COLLECTION': 'LIST', 'PFX': 'l', 'SNAME': 'list', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_queue.h"', 'LIB': 'CMC', 'COLLECTION': 'QUEUE', 'PFX': 'q', 'SNAME': 'queue', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_sortedlist.h"', 'LIB': 'CMC', 'COLLECTION': 'SORTEDLIST', 'PFX': 'sl', 'SNAME': 'sortedlist', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_stack.h"', 'LIB': 'CMC', 'COLLECTION': 'STACK', 'PFX': 's', 'SNAME': 'stack', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc_treemap.h"', 'LIB': 'CMC', 'COLLECTION': 'TREEMAP', 'PFX': 'tm', 'SNAME': 'treemap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc_treeset.h"', 'LIB': 'CMC', 'COLLECTION': 'TREESET', 'PFX': 'ts', 'SNAME': 'treeset', 'SIZE': '', 'K': '', 'V': 'size_t'}
|
||||
]
|
||||
|
||||
|
||||
# Just a realy helpfull overview
|
||||
CONFIG = f'''Directory Settings
|
||||
OUTPUT_DIR = {OUTPUT_DIR}
|
||||
ALL_LIBS = {ALL_LIBS}
|
||||
UNT_DIR = {UNT_DIR}
|
||||
DIR_MAP = {DIR_MAP}
|
||||
EXT_MAP = {EXT_MAP}
|
||||
BUILD_DIR = {BUILD_DIR}
|
||||
@@ -89,6 +122,10 @@ CONFIG = f'''Directory Settings
|
||||
SRC_DIR = {SRC_DIR}
|
||||
OBJ_DIR = {OBJ_DIR}
|
||||
GCOV_DIR = {GCOV_DIR}
|
||||
File Settings
|
||||
MAIN = {MAIN}
|
||||
CODECOV = {CODECOV}
|
||||
SINGLE = {SINGLE}
|
||||
Compiler Settings
|
||||
CC = {CC}
|
||||
CFLAGS = {CFLAGS}
|
||||
@@ -97,34 +134,13 @@ Compiler Settings
|
||||
GCOV_FLAGS = {GCOV_FLAGS}
|
||||
INCLUDE = {INCLUDE}
|
||||
TINCLUDE = {TINCLUDE}
|
||||
CVINCLUDE = {CVINCLUDE}
|
||||
Macro Expansion
|
||||
EXPAND_FLAGS = {EXPAND_FLAGS}
|
||||
UNIQUE_FLAG = {UNIQUE_FLAG}
|
||||
TMP_FILE = {TMP_FILE}'''
|
||||
|
||||
|
||||
# All collections that can be used for testing
|
||||
COLLECTIONS = [
|
||||
# header, library, collection, pfx, sname, size, key, val
|
||||
{'h': '"cmc/bitset.h"', 'LIB': 'CMC', 'COLLECTION': 'BITSET', 'PFX': 'bs', 'SNAME': 'bitset', 'SIZE': '', 'K': '', 'V': '' },
|
||||
{'h': '"cmc/deque.h"', 'LIB': 'CMC', 'COLLECTION': 'DEQUE', 'PFX': 'd', 'SNAME': 'deque', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/hashbidimap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHBIDIMAP', 'PFX': 'hbm', 'SNAME': 'hashbidimap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc/hashmap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMAP', 'PFX': 'hm', 'SNAME': 'hashmap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc/hashmultimap.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMULTIMAP', 'PFX': 'hmm', 'SNAME': 'hashmultimap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc/hashmultiset.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHMULTISET', 'PFX': 'hms', 'SNAME': 'hashmultiset', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/hashset.h"', 'LIB': 'CMC', 'COLLECTION': 'HASHSET', 'PFX': 'hs', 'SNAME': 'hashset', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/heap.h"', 'LIB': 'CMC', 'COLLECTION': 'HEAP', 'PFX': 'h', 'SNAME': 'heap', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/intervalheap.h"', 'LIB': 'CMC', 'COLLECTION': 'INTERVALHEAP', 'PFX': 'ih', 'SNAME': 'intervalheap', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/linkedlist.h"', 'LIB': 'CMC', 'COLLECTION': 'LINKEDLIST', 'PFX': 'll', 'SNAME': 'linkedlist', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/list.h"', 'LIB': 'CMC', 'COLLECTION': 'LIST', 'PFX': 'l', 'SNAME': 'list', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/queue.h"', 'LIB': 'CMC', 'COLLECTION': 'QUEUE', 'PFX': 'q', 'SNAME': 'queue', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/sortedlist.h"', 'LIB': 'CMC', 'COLLECTION': 'SORTEDLIST', 'PFX': 'sl', 'SNAME': 'sortedlist', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/stack.h"', 'LIB': 'CMC', 'COLLECTION': 'STACK', 'PFX': 's', 'SNAME': 'stack', 'SIZE': '', 'K': '', 'V': 'size_t'},
|
||||
{'h': '"cmc/treemap.h"', 'LIB': 'CMC', 'COLLECTION': 'TREEMAP', 'PFX': 'tm', 'SNAME': 'treemap', 'SIZE': '', 'K': 'size_t', 'V': 'size_t'},
|
||||
{'h': '"cmc/treeset.h"', 'LIB': 'CMC', 'COLLECTION': 'TREESET', 'PFX': 'ts', 'SNAME': 'treeset', 'SIZE': '', 'K': '', 'V': 'size_t'}
|
||||
]
|
||||
|
||||
|
||||
def full_path(path: Text) -> Text:
|
||||
'''
|
||||
Returns the full path of a 'path' with ralative paths, e.g. './' or '../'
|
||||
@@ -142,18 +158,28 @@ def execute_command(commands: List[Text]):
|
||||
# exit(1)
|
||||
|
||||
|
||||
def assert_executable(program: Text):
|
||||
def require_executable(program: Text):
|
||||
'''
|
||||
Asserts that a given program is installed and available in PATH.
|
||||
Asserts that a given program is installed and available in PATH. Raises an exception if it doesn't.
|
||||
'''
|
||||
if shutil.which(program) is None:
|
||||
raise Exception(f'The required executable {program} was not found in your path')
|
||||
|
||||
|
||||
def require_file(file: Text):
|
||||
'''
|
||||
Asserts that a given file exists. Raises an exception if it doesn't.
|
||||
'''
|
||||
f = pathlib.Path(file).resolve()
|
||||
if not f.is_file():
|
||||
raise Exception(f'The required file {str(f)} was not found')
|
||||
|
||||
|
||||
def assert_dir(directory: Text):
|
||||
'''
|
||||
Given a string 'directory' that is a path to a directory, make sure that it exists.
|
||||
'''
|
||||
# TODO change this to use pathlib ?
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
@@ -168,17 +194,20 @@ def assert_structure():
|
||||
for directory in DIR_MAP.values():
|
||||
assert_dir(f'{OUTPUT_DIR}/{directory}')
|
||||
|
||||
# For each library, create a directory for include and src
|
||||
for lib in ALL_LIBS:
|
||||
for directory in DIR_MAP.values():
|
||||
assert_dir(f'{OUTPUT_DIR}/{directory}/{lib.lower()}')
|
||||
|
||||
assert_dir(BUILD_DIR)
|
||||
assert_dir(OBJ_DIR)
|
||||
assert_dir(BIN_DIR)
|
||||
assert_dir(GCOV_DIR)
|
||||
|
||||
for lib in ALL_LIBS:
|
||||
assert_dir(f'{OBJ_DIR}/{lib.lower()}')
|
||||
|
||||
def format_code(source: bool, tests: bool):
|
||||
'''
|
||||
Format all source files from the main library or test files.
|
||||
'''
|
||||
if source:
|
||||
execute_command(['find', './src/', '-name', '*.h', '|', 'xargs', 'clang-format', '--style=file', '--verbose', '-i'])
|
||||
if tests:
|
||||
execute_command(['find', './tests/', '-name', '*.c', '-o', '-name', '*.h', '|', 'xargs', 'clang-format', '--style=file', '--verbose', '-i'])
|
||||
|
||||
|
||||
def clean_build(cleanfull: bool):
|
||||
@@ -186,9 +215,11 @@ def clean_build(cleanfull: bool):
|
||||
Removes all files generated by compilation and code coverage along with folders.
|
||||
'''
|
||||
# -f prevents 'rm' from failing
|
||||
execute_command(['rm', '-r', '-f', f'{GCOV_DIR}/*.gcov'])
|
||||
execute_command(['rm', '-f', TEST_EXE])
|
||||
execute_command(['rm', '-r', '-f', f'./*.gcov'])
|
||||
execute_command(['rm', '-r', '-f', f'{OUTPUT_DIR}/*.exe'])
|
||||
execute_command(['rm', '-r', '-f', BUILD_DIR])
|
||||
execute_command(['rm', '-f', './*.gcda'])
|
||||
execute_command(['rm', '-f', './*.gcno'])
|
||||
|
||||
if cleanfull:
|
||||
execute_command(['rm', '-r', SRC_DIR])
|
||||
@@ -210,7 +241,7 @@ def expand_code():
|
||||
|
||||
{UNIQUE_FLAG}
|
||||
|
||||
C_MACRO_COLLECTIONS_ALL_{ftype}({data['LIB']}, {data['COLLECTION']}, ({', '.join([data['PFX'], data['SNAME'], data['SIZE'], data['K'], data['V']])}))
|
||||
C_MACRO_COLLECTIONS_ALL_{ftype}({data['LIB']}, {data['COLLECTION']}, PUBLIC, ({', '.join([data['PFX'], data['SNAME'], data['SIZE'], data['K'], data['V']])}))
|
||||
|
||||
{UNIQUE_FLAG}
|
||||
''')
|
||||
@@ -228,7 +259,7 @@ def expand_code():
|
||||
print('Didn\'t match FLAG. Probably because compilation failed.', file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
file = open(f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/{data["LIB"].lower()}/{data["SNAME"]}.{EXT_MAP[ftype]}', 'w')
|
||||
file = open(f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/tst_{data["LIB"].lower()}_{data["SNAME"]}.{EXT_MAP[ftype]}', 'w')
|
||||
|
||||
if ftype == 'HEADER':
|
||||
file.write(
|
||||
@@ -244,7 +275,7 @@ def expand_code():
|
||||
else:
|
||||
file.write(
|
||||
f'''
|
||||
#include {data["h"]}
|
||||
#include {'"tst_' + data["h"][1:]}
|
||||
|
||||
{match.group("code")}
|
||||
''')
|
||||
@@ -252,7 +283,7 @@ def expand_code():
|
||||
file.flush()
|
||||
file.close()
|
||||
|
||||
print(f'Generated {data["h"]: >20} -> {OUTPUT_DIR}/{DIR_MAP[ftype]}/{data["LIB"].lower()}/{data["SNAME"]}.{EXT_MAP[ftype]}')
|
||||
print(f'''Generated {'"tst_' + data["h"][1:]: >24} -> {OUTPUT_DIR}/{DIR_MAP[ftype]}/tst_{data["LIB"].lower()}_{data["SNAME"]}.{EXT_MAP[ftype]}''')
|
||||
|
||||
os.remove(TMP_FILE)
|
||||
|
||||
@@ -262,71 +293,74 @@ def format_expand():
|
||||
Format the files outputted by 'expand_code'.
|
||||
'''
|
||||
cmd = ['clang-format', '--style=file', '--verbose', '-i']
|
||||
dirs_to_format = [f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/{lib.lower()}/*.{EXT_MAP[ftype]}' for ftype in DIR_MAP.keys() for lib in ALL_LIBS]
|
||||
dirs_to_format = [f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/*.{EXT_MAP[ftype]}' for ftype in DIR_MAP.keys()]
|
||||
cmd.extend(dirs_to_format)
|
||||
execute_command(cmd)
|
||||
|
||||
|
||||
def format_code(source: bool, tests: bool):
|
||||
def build_main():
|
||||
'''
|
||||
Format all source files from the main library or test files.
|
||||
Build all object files and main.c for tests.
|
||||
'''
|
||||
if source:
|
||||
execute_command(['find', './src/', '-name', '*.h', '|', 'xargs', 'clang-format', '--style=file', '--verbose', '-i'])
|
||||
if tests:
|
||||
execute_command(['find', './tests/', '-name', '*.c', '-o', '-name', '*.h', '|', 'xargs', 'clang-format', '--style=file', '--verbose', '-i'])
|
||||
|
||||
|
||||
def build_tests(with_coverage: bool):
|
||||
'''
|
||||
Build all object files and the main executable for tests
|
||||
'''
|
||||
cflags = CFLAGS.copy()
|
||||
|
||||
if with_coverage:
|
||||
cflags += CVFLAGS
|
||||
else:
|
||||
cflags += ['-O3']
|
||||
|
||||
for data in COLLECTIONS:
|
||||
cmd = [CC]
|
||||
cmd += cflags
|
||||
cmd += TINCLUDE # This one needs to go first
|
||||
cmd += INCLUDE
|
||||
cmd += ['-c', f"{SRC_DIR}/{data['LIB'].lower()}/{data['SNAME']}.c"]
|
||||
cmd += ['-o', f"{OBJ_DIR}/{data['LIB'].lower()}/{data['SNAME']}.o"]
|
||||
cmd += ['-c', f"{SRC_DIR}/tst_{data['LIB'].lower()}_{data['SNAME']}.c"]
|
||||
cmd += ['-o', f"{OBJ_DIR}/tst_{data['LIB'].lower()}_{data['SNAME']}.o"]
|
||||
execute_command(cmd)
|
||||
|
||||
# Build OUTPUT_DIR/main.c
|
||||
cmd = [CC]
|
||||
cmd += cflags
|
||||
cmd += TINCLUDE # This one needs to go first
|
||||
cmd += INCLUDE
|
||||
cmd += ['-c', f'{OUTPUT_DIR}/main.c']
|
||||
cmd += ['-o', f"{OBJ_DIR}/main.o"]
|
||||
cmd += ['-c', f'{OUTPUT_DIR}/{MAIN}.c']
|
||||
cmd += ['-o', f'{OBJ_DIR}/{MAIN}.o']
|
||||
execute_command(cmd)
|
||||
|
||||
# Link everything producing OUTPUT_DIR/main.exe
|
||||
cmd = [CC]
|
||||
cmd += cflags
|
||||
cmd += LFLAGS
|
||||
cmd += ['-o', TEST_EXE]
|
||||
cmd += ['-o', f'{BIN_DIR}/{MAIN}.exe']
|
||||
cmd += [f'{OBJ_DIR}/main.o']
|
||||
cmd += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.o' for data in COLLECTIONS]
|
||||
cmd += [f'{OBJ_DIR}/tst_{data["LIB"].lower()}_{data["SNAME"]}.o' for data in COLLECTIONS]
|
||||
execute_command(cmd)
|
||||
|
||||
|
||||
def run_tests(coverage: bool):
|
||||
def run_main():
|
||||
'''
|
||||
Runs tests. If coverage, run gcov.
|
||||
Runs main.exe
|
||||
'''
|
||||
execute_command([full_path(TEST_EXE)])
|
||||
execute_command([full_path(f'{BIN_DIR}/{MAIN}.exe')])
|
||||
|
||||
if coverage:
|
||||
objects = [f'{OBJ_DIR}/main.gcda']
|
||||
objects += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.gcda' for data in COLLECTIONS]
|
||||
execute_command(['gcov'] + GCOV_FLAGS + objects)
|
||||
execute_command(['mv', '*.gcov', GCOV_DIR])
|
||||
|
||||
def build_codecov():
|
||||
'''
|
||||
Builds codecov.c for code coverage.
|
||||
'''
|
||||
cmd = [CC]
|
||||
cmd += CVFLAGS
|
||||
cmd += CVINCLUDE # This one needs to go first
|
||||
cmd += INCLUDE
|
||||
cmd += [f'{OUTPUT_DIR}/{CODECOV}.c']
|
||||
cmd += ['-o', f'{BIN_DIR}/{CODECOV}.exe']
|
||||
execute_command(cmd)
|
||||
|
||||
|
||||
def run_codecov():
|
||||
'''
|
||||
Runs codecov.exe and then gcov on the generated gcda files. All gcov files then go to GCOV_DIR.
|
||||
'''
|
||||
execute_command([full_path(f'{BIN_DIR}/{CODECOV}.exe')])
|
||||
execute_command(['gcov'] + GCOV_FLAGS + [f'{CODECOV}.gcda'])
|
||||
execute_command(['rm', '*.h.gcov'])
|
||||
|
||||
|
||||
def tidy():
|
||||
'''
|
||||
Places files to their respective directory.
|
||||
'''
|
||||
execute_command(['mv', '*.gcov', GCOV_DIR])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -334,53 +368,69 @@ if __name__ == '__main__':
|
||||
|
||||
p.add_argument('-sc', '--show-config',
|
||||
help='Displays the current configuration',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='config')
|
||||
|
||||
tests = p.add_argument_group('tests', 'For dealing with tests')
|
||||
source = p.add_argument_group('source', 'For dealing with the source files and formatting')
|
||||
|
||||
tests.add_argument('-c', '--clean',
|
||||
expand = p.add_argument_group('expand', 'For dealing with code generation and formatting for tests')
|
||||
|
||||
task = p.add_argument_group('task', 'Specify a task (mutually exclusive)')
|
||||
task_ = task.add_mutually_exclusive_group()
|
||||
|
||||
action = p.add_argument_group('action', 'Actions on task')
|
||||
|
||||
task_.add_argument('-cv', '--codecov',
|
||||
help='Designates task as code coverage (uses codecov.c)',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='codecov')
|
||||
task_.add_argument('-m', '--main',
|
||||
help='Designates task as the main tests (uses main.c)',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='main')
|
||||
task_.add_argument('-s', '--single',
|
||||
help='Designates task as an individual test (uses single.c)',
|
||||
dest='single')
|
||||
|
||||
expand.add_argument('-c', '--clean',
|
||||
help='Cleans all build objects',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='clean')
|
||||
tests.add_argument('-cf', '--clean-full',
|
||||
expand.add_argument('-cf', '--clean-full',
|
||||
help='Cleans all build objects, source and header files, and removes folders',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='cleanfull')
|
||||
tests.add_argument('-e', '--expand',
|
||||
expand.add_argument('-e', '--expand',
|
||||
help='Expands the header and source files',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='expand')
|
||||
tests.add_argument('-nf', '--no-format',
|
||||
expand.add_argument('-nf', '--no-format',
|
||||
help='Does not format the output of expand. Can be used when you might not have clang-format',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='noformat')
|
||||
tests.add_argument('-b', '--build',
|
||||
help='Compile the object files and the main executable',
|
||||
expand.add_argument('-nt', '--no-tidy',
|
||||
help='Don\'t move files around',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='notidy')
|
||||
|
||||
action.add_argument('-b', '--build',
|
||||
help='Build task',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='build')
|
||||
tests.add_argument('-r', '--run',
|
||||
help='Runs tests, assuming that it is already built',
|
||||
action.add_argument('-r', '--run',
|
||||
help='Run task',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='run')
|
||||
tests.add_argument('-cv', '--coverage',
|
||||
help='Adds the code coverage flags for compilation',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='coverage')
|
||||
tests.add_argument('-rr', '--rerun',
|
||||
help='Compile the object files again and then run the tests',
|
||||
default=False,
|
||||
action='store_true',
|
||||
dest='rerun')
|
||||
|
||||
source = p.add_argument_group('source', 'For dealing with the source files and formatting')
|
||||
|
||||
source.add_argument('-fs', '--format-source',
|
||||
help='Format the source code',
|
||||
@@ -395,38 +445,58 @@ if __name__ == '__main__':
|
||||
|
||||
args = p.parse_args()
|
||||
|
||||
has_target = args.main or args.codecov or args.single
|
||||
|
||||
if args.config:
|
||||
print(CONFIG)
|
||||
exit(0)
|
||||
|
||||
if args.clean or args.cleanfull:
|
||||
clean_build(args.cleanfull)
|
||||
if args.fmt_source or args.fmt_tests:
|
||||
require_executable('find')
|
||||
require_executable('xargs')
|
||||
format_code(args.fmt_source, args.fmt_tests)
|
||||
# Prevent mixing code
|
||||
exit(0)
|
||||
|
||||
if not args.cleanfull:
|
||||
assert_structure()
|
||||
assert_executable(CC)
|
||||
if args.clean:
|
||||
clean_build(False)
|
||||
else:
|
||||
clean_build(True)
|
||||
# Nothing else will work, so just exit
|
||||
exit(0)
|
||||
|
||||
if args.expand:
|
||||
expand_code()
|
||||
if not args.noformat:
|
||||
assert_executable('clang-format')
|
||||
require_executable('clang-format')
|
||||
format_expand()
|
||||
else:
|
||||
# In case the next task is to build the code from source
|
||||
# This warning is a very annoying one from gcc
|
||||
CFLAGS += ['-Wno-misleading-indentation']
|
||||
|
||||
if args.fmt_source or args.fmt_tests:
|
||||
assert_executable('find')
|
||||
assert_executable('xargs')
|
||||
format_code(args.fmt_source, args.fmt_tests)
|
||||
|
||||
if args.build:
|
||||
build_tests(args.coverage)
|
||||
require_executable(CC)
|
||||
if args.codecov:
|
||||
require_executable('gcov')
|
||||
|
||||
if args.codecov:
|
||||
require_file(f'{OUTPUT_DIR}/{CODECOV}.c')
|
||||
if args.build:
|
||||
build_codecov()
|
||||
if args.run:
|
||||
run_tests(args.coverage)
|
||||
elif args.rerun:
|
||||
build_tests(args.coverage)
|
||||
run_tests(args.coverage)
|
||||
elif args.run:
|
||||
run_tests(args.coverage)
|
||||
run_codecov()
|
||||
elif args.main:
|
||||
require_file(f'{OUTPUT_DIR}/{MAIN}.c')
|
||||
if args.build:
|
||||
build_main()
|
||||
if args.run:
|
||||
run_main()
|
||||
elif args.single:
|
||||
require_file(f'{OUTPUT_DIR}/{SINGLE}.c')
|
||||
# TODO
|
||||
|
||||
if not args.notidy and args.codecov:
|
||||
tidy()
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include "../../util/twister.c"
|
||||
|
||||
C_MACRO_COLLECTIONS_ALL(CMC, HASHMULTIMAP, (hmm, hashmultimap, , uint64_t, uint64_t))
|
||||
CMC_CMC_HASHMULTIMAP_CORE(PUBLIC, HEADER, (hmm, hashmultimap, , uint64_t, uint64_t))
|
||||
CMC_CMC_HASHMULTIMAP_CORE(PUBLIC, SOURCE, (hmm, hashmultimap, , uint64_t, uint64_t))
|
||||
|
||||
int cmp(uint64_t a, uint64_t b)
|
||||
{
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
// needs to be generated first. Then, we can add other parts after. This macro
|
||||
// does all of that for us. The STR part will provide us with a function that
|
||||
// will be used later.
|
||||
C_MACRO_COLLECTIONS_GEN(CMC, LIST, MY_LIST_PARAMS, (STR))
|
||||
C_MACRO_COLLECTIONS_EXTENDED(CMC, LIST, MY_LIST_PARAMS, (STR))
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/bitset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_bitset.h
|
||||
*
|
||||
* Creation Date: 30/04/2020
|
||||
*
|
||||
@@ -34,12 +58,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* BitSet Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/bitset.h"
|
||||
#include "cor_bitset.h"
|
||||
|
||||
/**
|
||||
* Core BitSet implementation
|
||||
@@ -86,10 +110,10 @@
|
||||
/* Current array capacity */ \
|
||||
size_t capacity; \
|
||||
\
|
||||
/* Currently used bits */\
|
||||
/* This should always be true: */\
|
||||
/* capacity - count < sizeof(cmc_bitset_word) * CHAR_BIT */\
|
||||
size_t count;\
|
||||
/* Currently used bits */ \
|
||||
/* This should always be true: */ \
|
||||
/* capacity - count < sizeof(cmc_bitset_word) * CHAR_BIT */ \
|
||||
size_t count; \
|
||||
\
|
||||
/* Flags indicating errors or success */ \
|
||||
int flag; \
|
||||
@@ -156,7 +180,7 @@
|
||||
/* Iterator Initialization */ \
|
||||
/* Iterator State */ \
|
||||
/* Iterator Movement */ \
|
||||
/* Iterator Access */ \
|
||||
/* Iterator Access */
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Source
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/deque.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_deque.h
|
||||
*
|
||||
* Creation Date: 20/03/2019
|
||||
*
|
||||
@@ -34,7 +58,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core Deque implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/hashbidimap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_hashbidimap.h
|
||||
*
|
||||
* Creation Date: 26/09/2019
|
||||
*
|
||||
@@ -29,12 +53,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Hashtable Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/hashtable.h"
|
||||
#include "cor_hashtable.h"
|
||||
|
||||
/**
|
||||
* Core HashBidiMap implementation
|
||||
@@ -515,7 +539,7 @@
|
||||
} \
|
||||
\
|
||||
/* The mapping key -> new_val is already true */ \
|
||||
if (_map_->f_key->cmp(new_val, (*key_entry)->value) == 0) \
|
||||
if (_map_->f_val->cmp(new_val, (*key_entry)->value) == 0) \
|
||||
goto success; \
|
||||
\
|
||||
if (CMC_(PFX, _impl_get_entry_by_val)(_map_, new_val) != NULL) \
|
||||
@@ -657,7 +681,7 @@
|
||||
if (!entry) \
|
||||
{ \
|
||||
_map_->flag = CMC_FLAG_NOT_FOUND; \
|
||||
return (V){ 0 }; \
|
||||
return (K){ 0 }; \
|
||||
} \
|
||||
\
|
||||
_map_->flag = CMC_FLAG_OK; \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/hashmap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_hashmap.h
|
||||
*
|
||||
* Creation Date: 03/04/2019
|
||||
*
|
||||
@@ -22,12 +46,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Hashtable Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/hashtable.h"
|
||||
#include "cor_hashtable.h"
|
||||
|
||||
/**
|
||||
* Core HashMap implementation
|
||||
@@ -461,25 +485,21 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
K max_key = (K) { 0 }; \
|
||||
V max_val = (V) { 0 }; \
|
||||
size_t first = 0; \
|
||||
bool first = true; \
|
||||
K max_key = (K){ 0 }; \
|
||||
V max_val = (V){ 0 }; \
|
||||
\
|
||||
for (; first < _map_->capacity; first++) \
|
||||
{ \
|
||||
if (_map_->buffer[first].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
max_key = _map_->buffer[first].key; \
|
||||
max_val = _map_->buffer[first].value; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
for (size_t i = first + 1; i < _map_->capacity; i++) \
|
||||
for (size_t i = 0; i < _map_->capacity; i++) \
|
||||
{ \
|
||||
if (_map_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(_map_->buffer[i].key, max_key) > 0) \
|
||||
if (first) \
|
||||
{ \
|
||||
max_key = _map_->buffer[i].key; \
|
||||
max_val = _map_->buffer[i].value; \
|
||||
first = false; \
|
||||
} \
|
||||
else if (_map_->f_key->cmp(_map_->buffer[i].key, max_key) > 0) \
|
||||
{ \
|
||||
max_key = _map_->buffer[i].key; \
|
||||
max_val = _map_->buffer[i].value; \
|
||||
@@ -491,6 +511,8 @@
|
||||
*key = max_key; \
|
||||
if (value) \
|
||||
*value = max_val; \
|
||||
\
|
||||
_map_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_map_, read); \
|
||||
\
|
||||
@@ -505,25 +527,21 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
K min_key = (K) { 0 }; \
|
||||
V min_val = (V) { 0 }; \
|
||||
size_t first = 0; \
|
||||
bool first = true; \
|
||||
K min_key = (K){ 0 }; \
|
||||
V min_val = (V){ 0 }; \
|
||||
\
|
||||
for (; first < _map_->capacity; first++) \
|
||||
{ \
|
||||
if (_map_->buffer[first].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
min_key = _map_->buffer[first].key; \
|
||||
min_val = _map_->buffer[first].value; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
for (size_t i = first + 1; i < _map_->capacity; i++) \
|
||||
for (size_t i = 0; i < _map_->capacity; i++) \
|
||||
{ \
|
||||
if (_map_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(_map_->buffer[i].key, min_key) < 0) \
|
||||
if (first) \
|
||||
{ \
|
||||
min_key = _map_->buffer[i].key; \
|
||||
min_val = _map_->buffer[i].value; \
|
||||
first = false; \
|
||||
} \
|
||||
else if (_map_->f_key->cmp(_map_->buffer[i].key, min_key) < 0) \
|
||||
{ \
|
||||
min_key = _map_->buffer[i].key; \
|
||||
min_val = _map_->buffer[i].value; \
|
||||
@@ -535,6 +553,8 @@
|
||||
*key = min_key; \
|
||||
if (value) \
|
||||
*value = min_val; \
|
||||
\
|
||||
_map_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_map_, read); \
|
||||
\
|
||||
@@ -780,7 +800,6 @@
|
||||
if (_map_a_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry_a = &(_map_a_->buffer[i]); \
|
||||
\
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry_b = CMC_(PFX, _impl_get_entry)(_map_b_, entry_a->key); \
|
||||
\
|
||||
if (!entry_b) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/hashmultimap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_hashmultimap.h
|
||||
*
|
||||
* Creation Date: 26/04/2019
|
||||
*
|
||||
@@ -47,12 +71,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Hashtable Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/hashtable.h"
|
||||
#include "cor_hashtable.h"
|
||||
|
||||
/**
|
||||
* Core HashMultiMap implementation
|
||||
@@ -300,7 +324,7 @@
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[i][0]; \
|
||||
\
|
||||
while (scan != NULL) \
|
||||
while (scan) \
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *next = scan->next; \
|
||||
\
|
||||
@@ -329,7 +353,7 @@
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[index][0]; \
|
||||
\
|
||||
if (scan != NULL) \
|
||||
if (scan) \
|
||||
{ \
|
||||
if (scan->next == NULL && scan->prev == NULL) \
|
||||
{ \
|
||||
@@ -342,7 +366,7 @@
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
while (scan != NULL) \
|
||||
while (scan) \
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *tmp = scan; \
|
||||
\
|
||||
@@ -481,7 +505,7 @@
|
||||
\
|
||||
size_t index = 0; \
|
||||
\
|
||||
while (entry != NULL) \
|
||||
while (entry) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0) \
|
||||
{ \
|
||||
@@ -543,7 +567,7 @@
|
||||
{ \
|
||||
bool found = false; \
|
||||
\
|
||||
while (entry != NULL) \
|
||||
while (entry) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0) \
|
||||
{ \
|
||||
@@ -552,9 +576,9 @@
|
||||
if (*tail == entry) \
|
||||
*tail = entry->prev; \
|
||||
\
|
||||
if (entry->prev != NULL) \
|
||||
if (entry->prev) \
|
||||
entry->prev->next = entry->next; \
|
||||
if (entry->next != NULL) \
|
||||
if (entry->next) \
|
||||
entry->next->prev = entry->prev; \
|
||||
\
|
||||
if (out_value) \
|
||||
@@ -639,7 +663,7 @@
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
while (entry != NULL) \
|
||||
while (entry) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0) \
|
||||
{ \
|
||||
@@ -650,9 +674,9 @@
|
||||
\
|
||||
struct CMC_DEF_ENTRY(SNAME) *next = entry->next; \
|
||||
\
|
||||
if (entry->prev != NULL) \
|
||||
if (entry->prev) \
|
||||
entry->prev->next = entry->next; \
|
||||
if (entry->next != NULL) \
|
||||
if (entry->next) \
|
||||
entry->next->prev = entry->prev; \
|
||||
\
|
||||
if (out_values) \
|
||||
@@ -684,27 +708,30 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
K max_key = (K) { 0 }; \
|
||||
V max_val = (V) { 0 }; \
|
||||
bool first = true; \
|
||||
K max_key = (K){ 0 }; \
|
||||
V max_val = (V){ 0 }; \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map_); \
|
||||
\
|
||||
/* TODO Turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _map_->capacity; i++) \
|
||||
{ \
|
||||
K result_key = CMC_(PFX, _iter_key)(&iter); \
|
||||
V result_value = CMC_(PFX, _iter_value)(&iter); \
|
||||
size_t index = CMC_(PFX, _iter_index)(&iter); \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[i][0]; \
|
||||
\
|
||||
if (index == 0) \
|
||||
while (scan) \
|
||||
{ \
|
||||
max_key = result_key; \
|
||||
max_val = result_value; \
|
||||
} \
|
||||
else if (_map_->f_key->cmp(result_key, max_key) > 0) \
|
||||
{ \
|
||||
max_key = result_key; \
|
||||
max_val = result_value; \
|
||||
if (first) \
|
||||
{ \
|
||||
max_key = scan->key; \
|
||||
max_val = scan->value; \
|
||||
\
|
||||
first = false; \
|
||||
} \
|
||||
else if (_map_->f_key->cmp(scan->key, max_key) > 0) \
|
||||
{ \
|
||||
max_key = scan->key; \
|
||||
max_val = scan->value; \
|
||||
} \
|
||||
\
|
||||
scan = scan->next; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@@ -728,27 +755,30 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
K min_key = (K) { 0 }; \
|
||||
V min_val = (V) { 0 }; \
|
||||
bool first = true; \
|
||||
K min_key = (K){ 0 }; \
|
||||
V min_val = (V){ 0 }; \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map_); \
|
||||
\
|
||||
/* TODO Turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _map_->capacity; i++) \
|
||||
{ \
|
||||
K result_key = CMC_(PFX, _iter_key)(&iter); \
|
||||
V result_value = CMC_(PFX, _iter_value)(&iter); \
|
||||
size_t index = CMC_(PFX, _iter_index)(&iter); \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[i][0]; \
|
||||
\
|
||||
if (index == 0) \
|
||||
while (scan) \
|
||||
{ \
|
||||
min_key = result_key; \
|
||||
min_val = result_value; \
|
||||
} \
|
||||
else if (_map_->f_key->cmp(result_key, min_key) < 0) \
|
||||
{ \
|
||||
min_key = result_key; \
|
||||
min_val = result_value; \
|
||||
if (first) \
|
||||
{ \
|
||||
min_key = scan->key; \
|
||||
min_val = scan->value; \
|
||||
\
|
||||
first = false; \
|
||||
} \
|
||||
else if (_map_->f_key->cmp(scan->key, min_key) < 0) \
|
||||
{ \
|
||||
min_key = scan->key; \
|
||||
min_val = scan->value; \
|
||||
} \
|
||||
\
|
||||
scan = scan->next; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@@ -893,16 +923,17 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map_); \
|
||||
\
|
||||
/* TODO Turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _map_->capacity; i++) \
|
||||
{ \
|
||||
K key = CMC_(PFX, _iter_key)(&iter); \
|
||||
V value = CMC_(PFX, _iter_value)(&iter); \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[i][0]; \
|
||||
\
|
||||
/* TODO check for errors */ \
|
||||
CMC_(PFX, _insert)(_new_map_, key, value); \
|
||||
while (scan) \
|
||||
{ \
|
||||
/* TODO check for errors */ \
|
||||
CMC_(PFX, _insert)(_new_map_, scan->key, scan->value); \
|
||||
\
|
||||
scan = scan->next; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (_map_->count != _new_map_->count) \
|
||||
@@ -946,23 +977,28 @@
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map_); \
|
||||
\
|
||||
if (!CMC_(PFX, _empty)(_map_)) \
|
||||
for (size_t i = 0; i < _map_->capacity; i++) \
|
||||
{ \
|
||||
/* TODO Turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[i][0]; \
|
||||
\
|
||||
while (scan) \
|
||||
{ \
|
||||
K key = CMC_(PFX, _iter_key)(&iter); \
|
||||
V value = CMC_(PFX, _iter_value)(&iter); \
|
||||
K key; \
|
||||
V value; \
|
||||
\
|
||||
if (_map_->f_key->cpy) \
|
||||
key = _map_->f_key->cpy(key); \
|
||||
key = _map_->f_key->cpy(scan->key); \
|
||||
else \
|
||||
key = scan->key; \
|
||||
if (_map_->f_val->cpy) \
|
||||
value = _map_->f_val->cpy(value); \
|
||||
value = _map_->f_val->cpy(scan->value); \
|
||||
else \
|
||||
value = scan->value; \
|
||||
\
|
||||
/* TODO check for errors */ \
|
||||
CMC_(PFX, _insert)(result, key, value); \
|
||||
\
|
||||
scan = scan->next; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@@ -980,15 +1016,25 @@
|
||||
if (_map1_->count != _map2_->count) \
|
||||
return false; \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map1_); \
|
||||
/* Optimize loop using the smallest hashtable */ \
|
||||
struct SNAME *_map_a_; \
|
||||
struct SNAME *_map_b_; \
|
||||
\
|
||||
/* TODO Turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
_map_a_ = _map1_->capacity < _map2_->capacity ? _map1_ : _map2_; \
|
||||
_map_b_ = _map_a_ == _map1_ ? _map2_ : _map1_; \
|
||||
\
|
||||
for (size_t i = 0; i < _map_a_->capacity; i++) \
|
||||
{ \
|
||||
K key = CMC_(PFX, _iter_key)(&iter); \
|
||||
struct CMC_DEF_ENTRY(SNAME) *scan = _map_a_->buffer[i][0]; \
|
||||
\
|
||||
if (CMC_(PFX, _impl_key_count)(_map1_, key) != CMC_(PFX, _impl_key_count)(_map2_, key)) \
|
||||
return false; \
|
||||
while (scan) \
|
||||
{ \
|
||||
/* OPTIMIZE - This is calling key_count for repeating keys */ \
|
||||
if (CMC_(PFX, _impl_key_count)(_map_a_, scan->key) != CMC_(PFX, _impl_key_count)(_map_b_, scan->key)) \
|
||||
return false; \
|
||||
\
|
||||
scan = scan->next; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return true; \
|
||||
@@ -1015,7 +1061,7 @@
|
||||
\
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry = _map_->buffer[hash % _map_->capacity][0]; \
|
||||
\
|
||||
while (entry != NULL) \
|
||||
while (entry) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0) \
|
||||
return entry; \
|
||||
@@ -1037,7 +1083,7 @@
|
||||
if (!entry) \
|
||||
return total_count; \
|
||||
\
|
||||
while (entry != NULL) \
|
||||
while (entry) \
|
||||
{ \
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0) \
|
||||
total_count++; \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/hashmultiset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_hashmultiset.h
|
||||
*
|
||||
* Creation Date: 10/04/2019
|
||||
*
|
||||
@@ -29,12 +53,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Hashtable Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/hashtable.h"
|
||||
#include "cor_hashtable.h"
|
||||
|
||||
/**
|
||||
* Core HashMultiSet implementation
|
||||
@@ -477,19 +501,23 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
V max_val = (V) { 0 }; \
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set_); \
|
||||
bool first = true; \
|
||||
V max_val = (V){ 0 }; \
|
||||
\
|
||||
/* TODO transform this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_->capacity; i++) \
|
||||
{ \
|
||||
V result = CMC_(PFX, _iter_value)(&iter); \
|
||||
size_t index = CMC_(PFX, _iter_index)(&iter); \
|
||||
\
|
||||
if (index == 0) \
|
||||
max_val = result; \
|
||||
else if (_set_->f_val->cmp(result, max_val) > 0) \
|
||||
max_val = result; \
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
if (first) \
|
||||
{ \
|
||||
max_val = _set_->buffer[i].value; \
|
||||
first = false; \
|
||||
} \
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, max_val) > 0) \
|
||||
{ \
|
||||
max_val = _set_->buffer[i].value; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (value) \
|
||||
@@ -510,19 +538,23 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
V min_val = (V) { 0 }; \
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set_); \
|
||||
bool first = true; \
|
||||
V min_val = (V){ 0 }; \
|
||||
\
|
||||
/* TODO transform this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_->capacity; i++) \
|
||||
{ \
|
||||
V result = CMC_(PFX, _iter_value)(&iter); \
|
||||
size_t index = CMC_(PFX, _iter_index)(&iter); \
|
||||
\
|
||||
if (index == 0) \
|
||||
min_val = result; \
|
||||
else if (_set_->f_val->cmp(result, min_val) < 0) \
|
||||
min_val = result; \
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
if (first) \
|
||||
{ \
|
||||
min_val = _set_->buffer[i].value; \
|
||||
first = false; \
|
||||
} \
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, min_val) < 0) \
|
||||
{ \
|
||||
min_val = _set_->buffer[i].value; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (value) \
|
||||
@@ -631,13 +663,19 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set_); \
|
||||
\
|
||||
/* TODO transform this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_->capacity; i++) \
|
||||
{ \
|
||||
CMC_(PFX, _insert_many) \
|
||||
(_new_set_, CMC_(PFX, _iter_value)(&iter), CMC_(PFX, _iter_multiplicity)(&iter)); \
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
V value = _set_->buffer[i].value; \
|
||||
size_t multiplicity = _set_->buffer[i].multiplicity; \
|
||||
\
|
||||
/* TODO check this for possible errors where entry == NULL */ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry = CMC_(PFX, _impl_insert_and_return)(_new_set_, value, NULL); \
|
||||
\
|
||||
entry->multiplicity = multiplicity; \
|
||||
/* Setting cardinality not required, _new_set_ is temporary */ \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (_set_->count != _new_set_->count) \
|
||||
@@ -729,17 +767,26 @@
|
||||
if (_set1_->count == 0) \
|
||||
return true; \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set1_); \
|
||||
/* Optimize loop using the smallest hashtable */ \
|
||||
struct SNAME *_set_a_; \
|
||||
struct SNAME *_set_b_; \
|
||||
\
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
_set_a_ = _set1_->capacity < _set2_->capacity ? _set1_ : _set2_; \
|
||||
_set_b_ = _set_a_ == _set1_ ? _set2_ : _set1_; \
|
||||
\
|
||||
for (size_t i = 0; i < _set_a_->capacity; i++) \
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry = CMC_(PFX, _impl_get_entry)(_set2_, CMC_(PFX, _iter_value)(&iter)); \
|
||||
if (_set_a_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry_a = &(_set_a_->buffer[i]); \
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry_b = CMC_(PFX, _impl_get_entry)(_set_b_, entry_a->value); \
|
||||
\
|
||||
if (!entry) \
|
||||
return false; \
|
||||
if (!entry_b) \
|
||||
return false; \
|
||||
\
|
||||
if (entry->multiplicity != CMC_(PFX, _iter_multiplicity)(&iter)) \
|
||||
return false; \
|
||||
if (entry_a->multiplicity != entry_b->multiplicity) \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return true; \
|
||||
@@ -762,14 +809,16 @@
|
||||
/* something with it. This function only guarantees that there is */ \
|
||||
/* a valid entry for a given value */ \
|
||||
\
|
||||
*new_node = false; \
|
||||
if (new_node) \
|
||||
*new_node = false; \
|
||||
\
|
||||
struct CMC_DEF_ENTRY(SNAME) *entry = CMC_(PFX, _impl_get_entry)(_set_, value); \
|
||||
\
|
||||
if (entry != NULL) \
|
||||
return entry; \
|
||||
\
|
||||
*new_node = true; \
|
||||
if (new_node) \
|
||||
*new_node = true; \
|
||||
\
|
||||
if (CMC_(PFX, _full)(_set_)) \
|
||||
{ \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/hashset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_hashset.h
|
||||
*
|
||||
* Creation Date: 01/04/2019
|
||||
*
|
||||
@@ -22,12 +46,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Hashtable Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/hashtable.h"
|
||||
#include "cor_hashtable.h"
|
||||
|
||||
/**
|
||||
* Core HashSet implementation
|
||||
@@ -378,19 +402,23 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
V max_val = (V) { 0 }; \
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set_); \
|
||||
bool first = true; \
|
||||
V max_val = (V){ 0 }; \
|
||||
\
|
||||
/* TODO turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_->capacity; i++) \
|
||||
{ \
|
||||
V result = CMC_(PFX, _iter_value)(&iter); \
|
||||
size_t index = CMC_(PFX, _iter_index)(&iter); \
|
||||
\
|
||||
if (index == 0) \
|
||||
max_val = result; \
|
||||
else if (_set_->f_val->cmp(result, max_val) > 0) \
|
||||
max_val = result; \
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
if (first) \
|
||||
{ \
|
||||
max_val = _set_->buffer[i].value; \
|
||||
first = false; \
|
||||
} \
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, max_val) > 0) \
|
||||
{ \
|
||||
max_val = _set_->buffer[i].value; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (value) \
|
||||
@@ -411,19 +439,23 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
V min_val = (V) { 0 }; \
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set_); \
|
||||
bool first = true; \
|
||||
V min_val = (V){ 0 }; \
|
||||
\
|
||||
/* TODO turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_->capacity; i++) \
|
||||
{ \
|
||||
V result = CMC_(PFX, _iter_value)(&iter); \
|
||||
size_t index = CMC_(PFX, _iter_index)(&iter); \
|
||||
\
|
||||
if (index == 0) \
|
||||
min_val = result; \
|
||||
else if (_set_->f_val->cmp(result, min_val) < 0) \
|
||||
min_val = result; \
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
if (first) \
|
||||
{ \
|
||||
min_val = _set_->buffer[i].value; \
|
||||
first = false; \
|
||||
} \
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, min_val) < 0) \
|
||||
{ \
|
||||
min_val = _set_->buffer[i].value; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (value) \
|
||||
@@ -513,15 +545,15 @@
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set_); \
|
||||
\
|
||||
/* TODO turn this into a normal loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_->capacity; i++) \
|
||||
{ \
|
||||
V value = CMC_(PFX, _iter_value)(&iter); \
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
V value = _set_->buffer[i].value; \
|
||||
\
|
||||
/* TODO check for error */ \
|
||||
CMC_(PFX, _insert)(_new_set_, value); \
|
||||
/* TODO check this for possible errors */ \
|
||||
CMC_(PFX, _insert)(_new_set_, value); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
/* Unlikely */ \
|
||||
@@ -606,16 +638,21 @@
|
||||
if (_set1_->count != _set2_->count) \
|
||||
return false; \
|
||||
\
|
||||
if (_set1_->count == 0) \
|
||||
return true; \
|
||||
/* Optimize loop using the smallest hashtable */ \
|
||||
struct SNAME *_set_a_; \
|
||||
struct SNAME *_set_b_; \
|
||||
\
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_set1_); \
|
||||
_set_a_ = _set1_->capacity < _set2_->capacity ? _set1_ : _set2_; \
|
||||
_set_b_ = _set_a_ == _set1_ ? _set2_ : _set1_; \
|
||||
\
|
||||
/* TODO optimize this loop */ \
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
for (size_t i = 0; i < _set_a_->capacity; i++) \
|
||||
{ \
|
||||
if (CMC_(PFX, _impl_get_entry)(_set2_, CMC_(PFX, _iter_value)(&iter)) == NULL) \
|
||||
return false; \
|
||||
if (_set_a_->buffer[i].state == CMC_ES_FILLED) \
|
||||
{ \
|
||||
\
|
||||
if (!CMC_(PFX, _impl_get_entry)(_set_b_, _set_a_->buffer[i].value)) \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return true; \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/heap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_heap.h
|
||||
*
|
||||
* Creation Date: 25/03/2019
|
||||
*
|
||||
@@ -33,12 +57,12 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Heap Implementation
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/heap.h"
|
||||
#include "cor_heap.h"
|
||||
|
||||
/**
|
||||
* Core Heap implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/intervalheap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_intervalheap.h
|
||||
*
|
||||
* Creation Date: 06/07/2019
|
||||
*
|
||||
@@ -24,7 +48,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core IntervalHeap implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/linkedlist.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_linkedlist.h
|
||||
*
|
||||
* Creation Date: 22/03/2019
|
||||
*
|
||||
@@ -31,7 +55,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core LinkedList implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/list.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_list.h
|
||||
*
|
||||
* Creation Date: 12/02/2019
|
||||
*
|
||||
@@ -46,7 +70,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core List implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/queue.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_queue.h
|
||||
*
|
||||
* Creation Date: 15/02/2019
|
||||
*
|
||||
@@ -46,7 +70,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core Queue implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/sortedlist.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_sortedlist.h
|
||||
*
|
||||
* Creation Date: 17/09/2019
|
||||
*
|
||||
@@ -25,7 +49,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core SortedList implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/stack.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_stack.h
|
||||
*
|
||||
* Creation Date: 14/02/2019
|
||||
*
|
||||
@@ -31,7 +55,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core Stack implementation
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/treemap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_treemap.h
|
||||
*
|
||||
* Creation Date: 28/03/2019
|
||||
*
|
||||
@@ -22,7 +46,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core TreeMap implementation
|
||||
@@ -688,25 +712,57 @@
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
/* TODO turn this into a normal loop */ \
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map_); \
|
||||
struct CMC_DEF_NODE(SNAME) *root = _map_->root; \
|
||||
\
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
bool left_done = false; \
|
||||
\
|
||||
while (root) \
|
||||
{ \
|
||||
K key = CMC_(PFX, _iter_key)(&iter); \
|
||||
V value = CMC_(PFX, _iter_value)(&iter); \
|
||||
if (!left_done) \
|
||||
{ \
|
||||
while (root->left) \
|
||||
root = root->left; \
|
||||
} \
|
||||
\
|
||||
K key; \
|
||||
V value; \
|
||||
\
|
||||
if (_map_->f_key->cpy) \
|
||||
key = _map_->f_key->cpy(key); \
|
||||
key = _map_->f_key->cpy(root->key); \
|
||||
else \
|
||||
key = root->key; \
|
||||
if (_map_->f_val->cpy) \
|
||||
value = _map_->f_val->cpy(value); \
|
||||
value = _map_->f_val->cpy(root->value); \
|
||||
else \
|
||||
value = root->value; \
|
||||
\
|
||||
/* TODO check this for errors */ \
|
||||
CMC_(PFX, _insert)(result, key, value); \
|
||||
\
|
||||
left_done = true; \
|
||||
\
|
||||
if (root->right) \
|
||||
{ \
|
||||
left_done = false; \
|
||||
root = root->right; \
|
||||
} \
|
||||
else if (root->parent) \
|
||||
{ \
|
||||
while (root->parent && root == root->parent->right) \
|
||||
root = root->parent; \
|
||||
\
|
||||
if (!root->parent) \
|
||||
break; \
|
||||
\
|
||||
root = root->parent; \
|
||||
} \
|
||||
else \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
CMC_CALLBACKS_ASSIGN(result, _map_->callbacks); \
|
||||
_map_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_ASSIGN(result, _map_->callbacks); \
|
||||
\
|
||||
return result; \
|
||||
} \
|
||||
@@ -719,18 +775,46 @@
|
||||
if (_map1_->count != _map2_->count) \
|
||||
return false; \
|
||||
\
|
||||
/* TODO turn this into a normal loop */ \
|
||||
struct CMC_DEF_ITER(SNAME) iter = CMC_(PFX, _iter_start)(_map1_); \
|
||||
struct CMC_DEF_NODE(SNAME) *root = _map1_->root; \
|
||||
\
|
||||
for (; !CMC_(PFX, _iter_at_end)(&iter); CMC_(PFX, _iter_next)(&iter)) \
|
||||
bool left_done = false; \
|
||||
\
|
||||
while (root) \
|
||||
{ \
|
||||
struct CMC_DEF_NODE(SNAME) *node = CMC_(PFX, _impl_get_node)(_map2_, CMC_(PFX, _iter_key)(&iter)); \
|
||||
if (!left_done) \
|
||||
{ \
|
||||
while (root->left) \
|
||||
root = root->left; \
|
||||
} \
|
||||
\
|
||||
/* TODO this can be optimized by doing two in-order traversals */ \
|
||||
struct CMC_DEF_NODE(SNAME) *node = CMC_(PFX, _impl_get_node)(_map2_, root->key); \
|
||||
\
|
||||
if (node == NULL) \
|
||||
return false; \
|
||||
\
|
||||
if (_map1_->f_val->cmp(node->value, CMC_(PFX, _iter_value)(&iter)) != 0) \
|
||||
if (_map1_->f_val->cmp(node->value, root->value) != 0) \
|
||||
return false; \
|
||||
\
|
||||
left_done = true; \
|
||||
\
|
||||
if (root->right) \
|
||||
{ \
|
||||
left_done = false; \
|
||||
root = root->right; \
|
||||
} \
|
||||
else if (root->parent) \
|
||||
{ \
|
||||
while (root->parent && root == root->parent->right) \
|
||||
root = root->parent; \
|
||||
\
|
||||
if (!root->parent) \
|
||||
break; \
|
||||
\
|
||||
root = root->parent; \
|
||||
} \
|
||||
else \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
return true; \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cmc/treeset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cmc_treeset.h
|
||||
*
|
||||
* Creation Date: 27/03/2019
|
||||
*
|
||||
@@ -22,7 +46,7 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core TreeSet implementation
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* cor/alloc.h
|
||||
*
|
||||
* Creation Date: 24/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_ALLOC_H
|
||||
#define CMC_COR_ALLOC_H
|
||||
|
||||
#ifdef CMC_CAMEL_CASE
|
||||
#define CMC_ALLOC_NODE_NAME CMCAllocNode
|
||||
#else
|
||||
#define CMC_ALLOC_NODE_NAME cmc_alloc_node
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* struct cmc_alloc_node
|
||||
*
|
||||
* Custom allocation node. Allows collections to use custom allocation
|
||||
* functions. The cmc_alloc_node_default is the default heap allocator provided
|
||||
* by the standard library.
|
||||
*/
|
||||
static struct CMC_ALLOC_NODE_NAME
|
||||
{
|
||||
void *(*malloc)(size_t);
|
||||
void *(*calloc)(size_t, size_t);
|
||||
void *(*realloc)(void *, size_t);
|
||||
void (*free)(void *);
|
||||
} cmc_alloc_node_default = { malloc, calloc, realloc, free };
|
||||
|
||||
#endif /* CMC_COR_ALLOC_H */
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* cor/bitset.h
|
||||
*
|
||||
* Creation Date: 20/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Things commonly used by bitset collections.
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_BITSET_H
|
||||
#define CMC_COR_BITSET_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* 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;
|
||||
|
||||
/**
|
||||
* cmc_bit_to_index
|
||||
*
|
||||
* Translates a bit index to a word index
|
||||
*/
|
||||
static inline size_t cmc_bidx_to_widx(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;
|
||||
}
|
||||
|
||||
#endif /* CMC_COR_BITSET_H */
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* cor/flags.h
|
||||
*
|
||||
* Creation Date: 14/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_FLAGS_H
|
||||
#define CMC_COR_FLAGS_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
/**
|
||||
* enum cmc_flags
|
||||
*
|
||||
* Defines common error codes used by the entire library.
|
||||
*/
|
||||
// clang-format off
|
||||
enum cmc_flags
|
||||
{
|
||||
CMC_FLAG_OK = 0, // No errors
|
||||
CMC_FLAG_ALLOC = 1, // Allocation failed
|
||||
CMC_FLAG_EMPTY = 2, // The collection is empty when it should not
|
||||
CMC_FLAG_NOT_FOUND = 3, // Key or value not found
|
||||
CMC_FLAG_INVALID = 4, // Invalid argument or operation
|
||||
CMC_FLAG_RANGE = 5, // Index out of range
|
||||
CMC_FLAG_DUPLICATE = 6, // Duplicate key or value
|
||||
CMC_FLAG_ERROR = 7, // Generic error, usually caused by algorithm error
|
||||
CMC_FLAG_THREAD = 8, // Generic error regarding threads
|
||||
CMC_FLAG_MUTEX = 9 // Generic error regarding mutexes
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* cmc_flags_to_str
|
||||
*
|
||||
* Maps the error codes to their character representation.
|
||||
*/
|
||||
CMC_UNUSED static const char *cmc_flags_to_str[10] = { "OK", "ALLOC", "EMPTY", "NOT_FOUND", "INVALID",
|
||||
"RANGE", "DUPLICATE", "ERROR", "THREAD", "MUTEX" };
|
||||
|
||||
#endif /* CMC_COR_FLAGS_H */
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* cor/ftable.h
|
||||
*
|
||||
* Creation Date: 27/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Type definitions for Functions Tables.
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_FTABLE_H
|
||||
#define CMC_COR_FTABLE_H
|
||||
|
||||
/**
|
||||
* Where T can either be K or V
|
||||
*/
|
||||
#define CMC_DEF_FTAB_CMP(T) int (*cmp)(T, T)
|
||||
#define CMC_DEF_FTAB_CPY(T) T (*cpy)(T)
|
||||
#define CMC_DEF_FTAB_STR(T) bool (*str)(FILE *, T)
|
||||
#define CMC_DEF_FTAB_FREE(T) void (*free)(T)
|
||||
#define CMC_DEF_FTAB_HASH(T) size_t (*hash)(T)
|
||||
#define CMC_DEF_FTAB_PRI(T) int (*pri)(T, T)
|
||||
|
||||
#endif /* CMC_COR_FTABLE_H */
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* cor/heap.h
|
||||
*
|
||||
* Creation Date: 01/06/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Things commonly used by heap collections.
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_HEAP_H
|
||||
#define CMC_COR_HEAP_H
|
||||
|
||||
/**
|
||||
* enum cmc_heap_order
|
||||
*
|
||||
* Defines the two possible heaps:
|
||||
* - Max Heap has the greatest element at the top
|
||||
* - Min Heap has the smallest element at the top
|
||||
*/
|
||||
enum cmc_heap_order
|
||||
{
|
||||
CMC_MAX_HEAP = 1,
|
||||
CMC_MIN_HEAP = -1
|
||||
};
|
||||
|
||||
#endif /* CMC_COR_HEAP_H */
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_alloc.h
|
||||
*
|
||||
* Creation Date: 24/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_ALLOC_H
|
||||
#define CMC_COR_ALLOC_H
|
||||
|
||||
#ifdef CMC_CAMEL_CASE
|
||||
#define CMC_ALLOC_NODE_NAME CMCAllocNode
|
||||
#else
|
||||
#define CMC_ALLOC_NODE_NAME cmc_alloc_node
|
||||
#endif
|
||||
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* struct cmc_alloc_node
|
||||
*
|
||||
* Custom allocation node. Allows collections to use custom allocation
|
||||
* functions. The cmc_alloc_node_default is the default heap allocator provided
|
||||
* by the standard library.
|
||||
*/
|
||||
static struct CMC_ALLOC_NODE_NAME
|
||||
{
|
||||
void *(*malloc)(size_t);
|
||||
void *(*calloc)(size_t, size_t);
|
||||
void *(*realloc)(void *, size_t);
|
||||
void (*free)(void *);
|
||||
} CMC_UNUSED cmc_alloc_node_default = { malloc, calloc, realloc, free };
|
||||
|
||||
#endif /* CMC_COR_ALLOC_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_bitset.h
|
||||
*
|
||||
* Creation Date: 20/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Things commonly used by bitset collections.
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_BITSET_H
|
||||
#define CMC_COR_BITSET_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* 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;
|
||||
|
||||
/**
|
||||
* cmc_bidx_to_widx
|
||||
*
|
||||
* Translates a bit index to a word index
|
||||
*/
|
||||
static inline size_t cmc_bidx_to_widx(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;
|
||||
}
|
||||
|
||||
#endif /* CMC_COR_BITSET_H */
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cor/callbacks.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_callbacks.h
|
||||
*
|
||||
* Creation Date: 24/05/2020
|
||||
*
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cor/core.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_core.h
|
||||
*
|
||||
* Creation Date: 17/03/2020
|
||||
*
|
||||
@@ -35,10 +59,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "callbacks.h"
|
||||
#include "flags.h"
|
||||
#include "ftable.h"
|
||||
#include "cor_alloc.h"
|
||||
#include "cor_callbacks.h"
|
||||
#include "cor_flags.h"
|
||||
#include "cor_ftable.h"
|
||||
|
||||
#define CMC__(A, B) A##B
|
||||
#define CMC_(A, B) CMC__(A, B)
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_flags.h
|
||||
*
|
||||
* Creation Date: 14/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_FLAGS_H
|
||||
#define CMC_COR_FLAGS_H
|
||||
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* enum cmc_flags
|
||||
*
|
||||
* Defines common error codes used by the entire library.
|
||||
*/
|
||||
// clang-format off
|
||||
enum cmc_flags
|
||||
{
|
||||
CMC_FLAG_OK = 0, // No errors
|
||||
CMC_FLAG_ALLOC = 1, // Allocation failed
|
||||
CMC_FLAG_EMPTY = 2, // The collection is empty when it should not
|
||||
CMC_FLAG_NOT_FOUND = 3, // Key or value not found
|
||||
CMC_FLAG_INVALID = 4, // Invalid argument or operation
|
||||
CMC_FLAG_RANGE = 5, // Index out of range
|
||||
CMC_FLAG_DUPLICATE = 6, // Duplicate key or value
|
||||
CMC_FLAG_ERROR = 7, // Generic error, usually caused by algorithm error
|
||||
CMC_FLAG_THREAD = 8, // Generic error regarding threads
|
||||
CMC_FLAG_MUTEX = 9, // Generic error regarding mutexes
|
||||
CMC_FLAG_FULL = 10, // When a collection that doesn't resize is full
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* cmc_flags_to_str
|
||||
*
|
||||
* Maps the error codes to their character representation.
|
||||
*/
|
||||
CMC_UNUSED static const char *cmc_flags_to_str[11] = { "OK", "ALLOC", "EMPTY", "NOT_FOUND", "INVALID",
|
||||
"RANGE", "DUPLICATE", "ERROR", "THREAD", "MUTEX", "FULL" };
|
||||
|
||||
#endif /* CMC_COR_FLAGS_H */
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_ftable.h
|
||||
*
|
||||
* Creation Date: 27/05/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Type definitions for Functions Tables.
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_FTABLE_H
|
||||
#define CMC_COR_FTABLE_H
|
||||
|
||||
/**
|
||||
* Where T can either be K or V
|
||||
*/
|
||||
#define CMC_DEF_FTAB_CMP(T) int (*cmp)(T, T)
|
||||
#define CMC_DEF_FTAB_CPY(T) T (*cpy)(T)
|
||||
#define CMC_DEF_FTAB_STR(T) bool (*str)(FILE *, T)
|
||||
#define CMC_DEF_FTAB_FREE(T) void (*free)(T)
|
||||
#define CMC_DEF_FTAB_HASH(T) size_t (*hash)(T)
|
||||
#define CMC_DEF_FTAB_PRI(T) int (*pri)(T, T)
|
||||
|
||||
#endif /* CMC_COR_FTABLE_H */
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* cor/hashtable.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_hashtable.h
|
||||
*
|
||||
* Creation Date: 17/03/2020
|
||||
*
|
||||
@@ -15,7 +39,7 @@
|
||||
#ifndef CMC_COR_HASHTABLE_H
|
||||
#define CMC_COR_HASHTABLE_H
|
||||
|
||||
#include "core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* CMC_ENTRY_DELETED
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cor_heap.h
|
||||
*
|
||||
* Creation Date: 01/06/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Things commonly used by heap collections.
|
||||
*/
|
||||
|
||||
#ifndef CMC_COR_HEAP_H
|
||||
#define CMC_COR_HEAP_H
|
||||
|
||||
/**
|
||||
* enum cmc_heap_order
|
||||
*
|
||||
* Defines the two possible heaps:
|
||||
* - Max Heap has the greatest element at the top
|
||||
* - Min Heap has the smallest element at the top
|
||||
*/
|
||||
enum cmc_heap_order
|
||||
{
|
||||
CMC_MAX_HEAP = 1,
|
||||
CMC_MIN_HEAP = -1
|
||||
};
|
||||
|
||||
#endif /* CMC_COR_HEAP_H */
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* ext/cmc/bitset.h
|
||||
*
|
||||
* Creation Date: 08/06/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_EXT_CMC_BITSET_H
|
||||
#define CMC_EXT_CMC_BITSET_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC BitSet.
|
||||
*/
|
||||
#define CMC_EXT_CMC_BITSET_PARTS PLACEHOLDER
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_HEADER(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_SOURCE(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_HEADER_(PFX, SNAME, V)
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_SOURCE_(PFX, SNAME, V)
|
||||
|
||||
#endif /* CMC_EXT_CMC_BITSET_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_bitset.h
|
||||
*
|
||||
* Creation Date: 08/06/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_EXT_CMC_BITSET_H
|
||||
#define CMC_EXT_CMC_BITSET_H
|
||||
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC BitSet.
|
||||
*/
|
||||
#define CMC_EXT_CMC_BITSET_PARTS PLACEHOLDER
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_BITSET_PLACEHOLDER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_PUBLIC_HEADER(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_PUBLIC_SOURCE(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_PRIVATE_HEADER(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_PRIVATE_SOURCE(PARAMS)
|
||||
|
||||
#endif /* CMC_EXT_CMC_BITSET_H */
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/deque.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_deque.h
|
||||
*
|
||||
* Creation Date: 25/05/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_DEQUE_H
|
||||
#define CMC_EXT_CMC_DEQUE_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC Deque.
|
||||
@@ -23,17 +47,23 @@
|
||||
*
|
||||
* The part 'INIT' gives a new way of initializing a collection. The collection
|
||||
* struct is not heap allocated, only its internal structure (nodes, buffers).
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_DEQUE_INIT(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_INIT_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_INIT_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_DEQUE_INIT(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_DEQUE_INIT_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_INIT_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_INIT_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
/* INIT Extension can't be used with opaque struct */
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_PRIVATE_HEADER(PARAMS)
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_PRIVATE_SOURCE(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_INIT_HEADER_(PFX, SNAME, V) \
|
||||
\
|
||||
struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); \
|
||||
@@ -98,15 +128,23 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_DEQUE_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_DEQUE_ITER(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_DEQUE_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -363,15 +401,23 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_DEQUE_STR(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_DEQUE_STR(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_DEQUE_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_DEQUE_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_DEQUE_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_DEQUE_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_DEQUE_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/hashbidimap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_hashbidimap.h
|
||||
*
|
||||
* Creation Date: 26/05/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_HASHBIDIMAP_H
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC HashBidiMap.
|
||||
@@ -20,16 +44,27 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR(PARAMS) \
|
||||
CMC_EXT_CMC_HASHBIDIMAP_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHBIDIMAP_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHBIDIMAP_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHBIDIMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHBIDIMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHBIDIMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHBIDIMAP_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHBIDIMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/hashmap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_hashmap.h
|
||||
*
|
||||
* Creation Date: 25/05/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_HASHMAP_H
|
||||
#define CMC_EXT_CMC_HASHMAP_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC HashMap.
|
||||
@@ -21,18 +45,26 @@
|
||||
/**
|
||||
* INIT
|
||||
*
|
||||
* The part 'INIT' gives a new way of initializing a collection. The collection
|
||||
* struct is not heap allocated, only its internal structure (nodes, buffers).
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_INIT_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_INIT_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMAP_INIT_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_INIT_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_INIT_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_INIT_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_INIT_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_INIT_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -116,16 +148,27 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMAP_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -441,16 +484,27 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMAP_STR(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMAP_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMAP_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMAP_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMAP_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMAP_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/hashmultimap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_hashmultimap.h
|
||||
*
|
||||
* Creation Date: 29/05/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_HASHMULTIMAP_H
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC HashMultiMap.
|
||||
@@ -20,16 +44,27 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMULTIMAP_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -370,16 +405,27 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMULTIMAP_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTIMAP_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTIMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/hashmultiset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_hashmultiset.h
|
||||
*
|
||||
* Creation Date: 30/05/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_HASHMULTISET_H
|
||||
#define CMC_EXT_CMC_HASHMULTISET_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC HashMultiSet.
|
||||
@@ -20,15 +44,24 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMULTISET_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -334,15 +367,24 @@
|
||||
|
||||
/**
|
||||
* SETF
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_SETF_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_SETF_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMULTISET_SETF_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_SETF_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_SETF_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_SETF_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_SETF_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_SETF_HEADER_(PFX, SNAME, V) \
|
||||
@@ -617,15 +659,24 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHMULTISET_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHMULTISET_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHMULTISET_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/hashset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_hashset.h
|
||||
*
|
||||
* Creation Date: 29/05/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_HASHSET_H
|
||||
#define CMC_EXT_CMC_HASHSET_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC HashSet.
|
||||
@@ -20,15 +44,24 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHSET_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHSET_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHSET_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -325,15 +358,24 @@
|
||||
|
||||
/**
|
||||
* SETF
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHSET_SETF(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_SETF_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_SETF_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHSET_SETF(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHSET_SETF_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_SETF_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_SETF_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_SETF_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_SETF_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_SETF_HEADER_(PFX, SNAME, V) \
|
||||
@@ -591,15 +633,24 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HASHSET_STR(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HASHSET_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_HASHSET_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHSET_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HASHSET_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HASHSET_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HASHSET_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/heap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_heap.h
|
||||
*
|
||||
* Creation Date: 01/06/2020
|
||||
*
|
||||
@@ -11,21 +35,32 @@
|
||||
#ifndef CMC_EXT_CMC_HEAP_H
|
||||
#define CMC_EXT_CMC_HEAP_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC Heap.
|
||||
*/
|
||||
#define CMC_EXT_CMC_HEAP_PARTS ITER, STR
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_ITER_SOURCE(PARAMS)
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HEAP_ITER(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_HEAP_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HEAP_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HEAP_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -244,15 +279,23 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_HEAP_STR(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_HEAP_STR(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_HEAP_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_HEAP_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_HEAP_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_HEAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_HEAP_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/intervalheap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_intervalheap.h
|
||||
*
|
||||
* Creation Date: 02/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_INTERVALHEAP_H
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC IntervalHeap.
|
||||
@@ -20,15 +44,24 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_INTERVALHEAP_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -247,15 +280,24 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_INTERVALHEAP_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_INTERVALHEAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_INTERVALHEAP_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/linkedlist.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_linkedlist.h
|
||||
*
|
||||
* Creation Date: 03/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_LINKEDLIST_H
|
||||
#define CMC_EXT_CMC_LINKEDLIST_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC LinkedList.
|
||||
@@ -20,15 +44,24 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_LINKEDLIST_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -274,15 +307,24 @@
|
||||
|
||||
/**
|
||||
* NODE
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_NODE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_NODE_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_LINKEDLIST_NODE_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_NODE_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_NODE_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_NODE_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_NODE_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_NODE_HEADER_(PFX, SNAME, V) \
|
||||
@@ -504,15 +546,24 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_LINKEDLIST_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LINKEDLIST_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LINKEDLIST_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/list.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_list.h
|
||||
*
|
||||
* Creation Date: 04/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_LIST_H
|
||||
#define CMC_EXT_CMC_LIST_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC List.
|
||||
@@ -20,15 +44,23 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_LIST_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_LIST_ITER(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_LIST_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_LIST_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_LIST_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_LIST_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -253,15 +285,23 @@
|
||||
|
||||
/**
|
||||
* SEQ
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_LIST_SEQ(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_SEQ_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_SEQ_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_LIST_SEQ(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_LIST_SEQ_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_LIST_SEQ_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_LIST_SEQ_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_SEQ_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_SEQ_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_LIST_SEQ_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_SEQ_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_SEQ_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_SEQ_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_SEQ_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_SEQ_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_SEQ_HEADER_(PFX, SNAME, V) \
|
||||
@@ -433,15 +473,23 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_LIST_STR(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_LIST_STR(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_LIST_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_LIST_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_LIST_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_LIST_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_LIST_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_LIST_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/queue.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_queue.h
|
||||
*
|
||||
* Creation Date: 05/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_QUEUE_H
|
||||
#define CMC_EXT_CMC_QUEUE_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC Queue.
|
||||
@@ -20,15 +44,23 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_QUEUE_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_QUEUE_ITER(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_QUEUE_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -285,15 +317,23 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_QUEUE_STR(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_QUEUE_STR(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_QUEUE_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_QUEUE_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_QUEUE_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_QUEUE_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_QUEUE_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/sortedlist.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_sortedlist.h
|
||||
*
|
||||
* Creation Date: 06/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_SORTEDLIST_H
|
||||
#define CMC_EXT_CMC_SORTEDLIST_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC SortedList.
|
||||
@@ -20,15 +44,24 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_SORTEDLIST_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -248,15 +281,24 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_SORTEDLIST_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_SORTEDLIST_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_SORTEDLIST_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/stack.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_stack.h
|
||||
*
|
||||
* Creation Date: 07/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_STACK_H
|
||||
#define CMC_EXT_CMC_STACK_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC Stack.
|
||||
@@ -20,15 +44,23 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_STACK_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_STACK_ITER(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_STACK_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_STACK_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_STACK_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_STACK_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -256,15 +288,23 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_STACK_STR(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_STACK_STR(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_EXT_CMC_STACK_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_STACK_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_STACK_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_STACK_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_STACK_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_STACK_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/treemap.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_treemap.h
|
||||
*
|
||||
* Creation Date: 08/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_TREEMAP_H
|
||||
#define CMC_EXT_CMC_TREEMAP_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC TreeMap.
|
||||
@@ -20,16 +44,27 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_TREEMAP_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -346,16 +381,27 @@
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_TREEMAP_STR(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_TREEMAP_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_TREEMAP_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREEMAP_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREEMAP_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREEMAP_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREEMAP_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_K(PARAMS), \
|
||||
CMC_PARAM_V(PARAMS))
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* ext/cmc/treeset.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_cmc_treeset.h
|
||||
*
|
||||
* Creation Date: 08/06/2020
|
||||
*
|
||||
@@ -11,7 +35,7 @@
|
||||
#ifndef CMC_EXT_CMC_TREESET_H
|
||||
#define CMC_EXT_CMC_TREESET_H
|
||||
|
||||
#include "../../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of CMC TreeSet.
|
||||
@@ -20,15 +44,24 @@
|
||||
|
||||
/**
|
||||
* ITER
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_TREESET_ITER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_ITER_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_ITER_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_TREESET_ITER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_TREESET_ITER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_ITER_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREESET_ITER_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_ITER_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREESET_ITER_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_ITER_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_ITER_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_ITER_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_ITER_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_ITER_HEADER_(PFX, SNAME, V) \
|
||||
@@ -326,15 +359,24 @@
|
||||
|
||||
/**
|
||||
* SETF
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_TREESET_SETF(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_SETF_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_SETF_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_TREESET_SETF(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_TREESET_SETF_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_SETF_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREESET_SETF_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_SETF_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_SETF_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREESET_SETF_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_SETF_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_SETF_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_SETF_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_SETF_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_SETF_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_SETF_HEADER_(PFX, SNAME, V) \
|
||||
@@ -557,18 +599,26 @@
|
||||
return true; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* STR
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_EXT_CMC_TREESET_STR(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_STR_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_STR_SOURCE(PARAMS)
|
||||
#define CMC_EXT_CMC_TREESET_STR(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_CMC_TREESET_STR_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_STR_HEADER(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREESET_STR_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_STR_SOURCE(PARAMS) \
|
||||
#define CMC_EXT_CMC_TREESET_STR_PUBLIC_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_STR_PRIVATE_HEADER(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_STR_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_STR_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_EXT_CMC_TREESET_STR_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_EXT_CMC_TREESET_STR_HEADER_(PFX, SNAME, V) \
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ext_sac_list.h
|
||||
*
|
||||
* Creation Date: 06/10/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CMC_EXT_SAC_LIST_H
|
||||
#define CMC_EXT_SAC_LIST_H
|
||||
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* All the EXT parts of SAC List.
|
||||
*/
|
||||
#define CMC_EXT_SAC_LIST_PARTS PLACEHOLDER
|
||||
|
||||
#define CMC_EXT_SAC_LIST_PLACEHOLDER(ACCESS, FILE, PARAMS) \
|
||||
CMC_(CMC_(CMC_EXT_SAC_LIST_PLACEHOLDER_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
#define CMC_EXT_SAC_LIST_PLACEHOLDER_PUBLIC_HEADER(PARAMS)
|
||||
|
||||
#define CMC_EXT_SAC_LIST_PLACEHOLDER_PUBLIC_SOURCE(PARAMS)
|
||||
|
||||
#define CMC_EXT_SAC_LIST_PLACEHOLDER_PRIVATE_HEADER(PARAMS)
|
||||
|
||||
#define CMC_EXT_SAC_LIST_PLACEHOLDER_PRIVATE_SOURCE(PARAMS)
|
||||
|
||||
#endif /* CMC_EXT_SAC_LIST_H */
|
||||
+154
-109
@@ -1,3 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* macro_collections.h
|
||||
*
|
||||
@@ -16,9 +40,10 @@
|
||||
* from any given sub-library. They are:
|
||||
*
|
||||
* - C_MACRO_COLLECTIONS
|
||||
* - C_MACRO_COLLECTIONS_GEN
|
||||
* - C_MACRO_COLLECTIONS_GEN_HEADER
|
||||
* - C_MACRO_COLLECTIONS_GEN_SOURCE
|
||||
* - C_MACRO_COLLECTIONS_INLINE
|
||||
* - C_MACRO_COLLECTIONS_EXTENDED
|
||||
* - C_MACRO_COLLECTIONS_EXTENDED_HEADER
|
||||
* - C_MACRO_COLLECTIONS_EXTENDED_SOURCE
|
||||
* - C_MACRO_COLLECTIONS_ALL
|
||||
* - C_MACRO_COLLECTIONS_ALL_HEADER
|
||||
* - C_MACRO_COLLECTIONS_ALL_SOURCE
|
||||
@@ -27,57 +52,60 @@
|
||||
#define CMC_MACRO_COLLECTIONS_H
|
||||
|
||||
// clang-format off
|
||||
#include "cmc/bitset.h" /* Added in 30/04/2020 */
|
||||
#include "cmc/deque.h" /* Added in 20/03/2019 */
|
||||
#include "cmc/hashbidimap.h" /* Added in 26/09/2019 */
|
||||
#include "cmc/hashmap.h" /* Added in 03/04/2019 */
|
||||
#include "cmc/hashmultimap.h" /* Added in 26/04/2019 */
|
||||
#include "cmc/hashmultiset.h" /* Added in 10/04/2019 */
|
||||
#include "cmc/hashset.h" /* Added in 01/04/2019 */
|
||||
#include "cmc/heap.h" /* Added in 25/03/2019 */
|
||||
#include "cmc/intervalheap.h" /* Added in 06/07/2019 */
|
||||
#include "cmc/linkedlist.h" /* Added in 22/03/2019 */
|
||||
#include "cmc/list.h" /* Added in 12/02/2019 */
|
||||
#include "cmc/queue.h" /* Added in 15/02/2019 */
|
||||
#include "cmc/sortedlist.h" /* Added in 17/09/2019 */
|
||||
#include "cmc/stack.h" /* Added in 14/02/2019 */
|
||||
#include "cmc/treemap.h" /* Added in 28/03/2019 */
|
||||
#include "cmc/treeset.h" /* Added in 27/03/2019 */
|
||||
#include "cmc_bitset.h" /* Added in 30/04/2020 */
|
||||
#include "cmc_deque.h" /* Added in 20/03/2019 */
|
||||
#include "cmc_hashbidimap.h" /* Added in 26/09/2019 */
|
||||
#include "cmc_hashmap.h" /* Added in 03/04/2019 */
|
||||
#include "cmc_hashmultimap.h" /* Added in 26/04/2019 */
|
||||
#include "cmc_hashmultiset.h" /* Added in 10/04/2019 */
|
||||
#include "cmc_hashset.h" /* Added in 01/04/2019 */
|
||||
#include "cmc_heap.h" /* Added in 25/03/2019 */
|
||||
#include "cmc_intervalheap.h" /* Added in 06/07/2019 */
|
||||
#include "cmc_linkedlist.h" /* Added in 22/03/2019 */
|
||||
#include "cmc_list.h" /* Added in 12/02/2019 */
|
||||
#include "cmc_queue.h" /* Added in 15/02/2019 */
|
||||
#include "cmc_sortedlist.h" /* Added in 17/09/2019 */
|
||||
#include "cmc_stack.h" /* Added in 14/02/2019 */
|
||||
#include "cmc_treemap.h" /* Added in 28/03/2019 */
|
||||
#include "cmc_treeset.h" /* Added in 27/03/2019 */
|
||||
|
||||
#include "cor/alloc.h" /* Added in 24/05/2020 */
|
||||
#include "cor/bitset.h" /* Added in 20/05/2020 */
|
||||
#include "cor/callbacks.h" /* Added in 24/05/2020 */
|
||||
#include "cor/core.h" /* Added in 17/03/2020 */
|
||||
#include "cor/flags.h" /* Added in 14/05/2020 */
|
||||
#include "cor/ftable.h" /* Added in 27/05/2020 */
|
||||
#include "cor/hashtable.h" /* Added in 17/03/2020 */
|
||||
#include "cor/heap.h" /* Added in 01/06/2020 */
|
||||
#include "cor_alloc.h" /* Added in 24/05/2020 */
|
||||
#include "cor_bitset.h" /* Added in 20/05/2020 */
|
||||
#include "cor_callbacks.h" /* Added in 24/05/2020 */
|
||||
#include "cor_core.h" /* Added in 17/03/2020 */
|
||||
#include "cor_flags.h" /* Added in 14/05/2020 */
|
||||
#include "cor_ftable.h" /* Added in 27/05/2020 */
|
||||
#include "cor_hashtable.h" /* Added in 17/03/2020 */
|
||||
#include "cor_heap.h" /* Added in 01/06/2020 */
|
||||
|
||||
#include "ext/cmc/bitset.h" /* Added in 08/06/2020 */
|
||||
#include "ext/cmc/deque.h" /* Added in 25/05/2020 */
|
||||
#include "ext/cmc/hashbidimap.h" /* Added in 26/05/2020 */
|
||||
#include "ext/cmc/hashmap.h" /* Added in 25/05/2020 */
|
||||
#include "ext/cmc/hashmultimap.h" /* Added in 29/05/2020 */
|
||||
#include "ext/cmc/hashmultiset.h" /* Added in 30/05/2020 */
|
||||
#include "ext/cmc/hashset.h" /* Added in 31/05/2020 */
|
||||
#include "ext/cmc/heap.h" /* Added in 01/06/2020 */
|
||||
#include "ext/cmc/intervalheap.h" /* Added in 02/06/2020 */
|
||||
#include "ext/cmc/linkedlist.h" /* Added in 03/06/2020 */
|
||||
#include "ext/cmc/list.h" /* Added in 04/06/2020 */
|
||||
#include "ext/cmc/queue.h" /* Added in 05/06/2020 */
|
||||
#include "ext/cmc/sortedlist.h" /* Added in 06/06/2020 */
|
||||
#include "ext/cmc/stack.h" /* Added in 07/06/2020 */
|
||||
#include "ext/cmc/treemap.h" /* Added in 08/06/2020 */
|
||||
#include "ext/cmc/treeset.h" /* Added in 08/06/2020 */
|
||||
#include "ext_cmc_bitset.h" /* Added in 08/06/2020 */
|
||||
#include "ext_cmc_deque.h" /* Added in 25/05/2020 */
|
||||
#include "ext_cmc_hashbidimap.h" /* Added in 26/05/2020 */
|
||||
#include "ext_cmc_hashmap.h" /* Added in 25/05/2020 */
|
||||
#include "ext_cmc_hashmultimap.h" /* Added in 29/05/2020 */
|
||||
#include "ext_cmc_hashmultiset.h" /* Added in 30/05/2020 */
|
||||
#include "ext_cmc_hashset.h" /* Added in 31/05/2020 */
|
||||
#include "ext_cmc_heap.h" /* Added in 01/06/2020 */
|
||||
#include "ext_cmc_intervalheap.h" /* Added in 02/06/2020 */
|
||||
#include "ext_cmc_linkedlist.h" /* Added in 03/06/2020 */
|
||||
#include "ext_cmc_list.h" /* Added in 04/06/2020 */
|
||||
#include "ext_cmc_queue.h" /* Added in 05/06/2020 */
|
||||
#include "ext_cmc_sortedlist.h" /* Added in 06/06/2020 */
|
||||
#include "ext_cmc_stack.h" /* Added in 07/06/2020 */
|
||||
#include "ext_cmc_treemap.h" /* Added in 08/06/2020 */
|
||||
#include "ext_cmc_treeset.h" /* Added in 08/06/2020 */
|
||||
#include "ext_sac_list.h" /* Added in 08/06/2020 */
|
||||
|
||||
#include "utl/assert.h" /* Added in 27/06/2019 */
|
||||
#include "utl/foreach.h" /* Added in 25/02/2019 */
|
||||
#include "utl/futils.h" /* Added in 15/04/2020 */
|
||||
#include "utl/log.h" /* Added in 21/06/2019 */
|
||||
#include "utl/mutex.h" /* Added in 14/05/2020 */
|
||||
#include "utl/test.h" /* Added in 26/06/2019 */
|
||||
#include "utl/thread.h" /* Added in 14/05/2020 */
|
||||
#include "utl/timer.h" /* Added in 12/04/2019 */
|
||||
#include "sac_list.h" /* Added in 06/10/2020 */
|
||||
|
||||
#include "utl_assert.h" /* Added in 27/06/2019 */
|
||||
#include "utl_foreach.h" /* Added in 25/02/2019 */
|
||||
#include "utl_futils.h" /* Added in 15/04/2020 */
|
||||
#include "utl_log.h" /* Added in 21/06/2019 */
|
||||
#include "utl_mutex.h" /* Added in 14/05/2020 */
|
||||
#include "utl_test.h" /* Added in 26/06/2019 */
|
||||
#include "utl_thread.h" /* Added in 14/05/2020 */
|
||||
#include "utl_timer.h" /* Added in 12/04/2019 */
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
@@ -88,15 +116,31 @@
|
||||
* \param LIB The collection's sub-library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param PART The part of the collection (either CORE or one available at EXT)
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
C_MACRO_COLLECTIONS_(LIB, COLLECTION, PART, FILE)(PARAMS)
|
||||
#define C_MACRO_COLLECTIONS_(LIB, COLLECTION, PART, FILE) CMC_##LIB##_##COLLECTION##_##PART##_##FILE
|
||||
#define C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
C_MACRO_COLLECTIONS_(LIB, COLLECTION, PART, ACCESS, FILE)(PARAMS)
|
||||
|
||||
#define C_MACRO_COLLECTIONS_(LIB, COLLECTION, PART, ACCESS, FILE) CMC_##LIB##_##COLLECTION##_##PART##_##ACCESS##_##FILE
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_GEN
|
||||
* C_MACRO_COLLECTIONS_INLINE
|
||||
*
|
||||
* Generates both HEADER and SOURCE one after the other of a certain PART of a certain LIB.
|
||||
*
|
||||
* \param LIB The collection's sub-library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param PART The part of the collection (either CORE or one available at EXT)
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_INLINE(LIB, COLLECTION, PART, PARAMS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, PUBLIC, HEADER, PARAMS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, PUBLIC, SOURCE, PARAMS)
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_EXTENDED
|
||||
*
|
||||
* Generate the CORE of a collection along with one or more part from EXT. The
|
||||
* headers are generated first, then the source code.
|
||||
@@ -106,37 +150,39 @@
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
* \param PARTS A non-empty tuple of all desired EXT parts
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_GEN(LIB, COLLECTION, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS_GEN_HEADER(LIB, COLLECTION, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS_GEN_SOURCE(LIB, COLLECTION, PARAMS, PARTS)
|
||||
#define C_MACRO_COLLECTIONS_EXTENDED(LIB, COLLECTION, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS_EXTENDED_HEADER(LIB, COLLECTION, PUBLIC, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS_EXTENDED_SOURCE(LIB, COLLECTION, PUBLIC, PARAMS, PARTS)
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_GEN_HEADER
|
||||
* C_MACRO_COLLECTIONS_EXTENDED_HEADER
|
||||
*
|
||||
* Generate all headers of CORE and the specified header parts of a collection.
|
||||
*
|
||||
* \param LIB The collection's sub-library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
* \param PARTS A non-empty tuple of all desired EXT parts
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_GEN_HEADER(LIB, COLLECTION, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE_PUBLIC, HEADER, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, HEADER, PARAMS, CMC_EVAL PARTS)
|
||||
#define C_MACRO_COLLECTIONS_EXTENDED_HEADER(LIB, COLLECTION, ACCESS, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE, ACCESS, HEADER, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, ACCESS, HEADER, PARAMS, CMC_EVAL PARTS)
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_GEN_SOURCE
|
||||
* C_MACRO_COLLECTIONS_EXTENDED_SOURCE
|
||||
*
|
||||
* Generate all sources of CORE and the specified source parts of a collection.
|
||||
*
|
||||
* \param LIB The collection's sub-library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
* \param PARTS A non-empty tuple of all desired EXT parts
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_GEN_SOURCE(LIB, COLLECTION, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE_PUBLIC, SOURCE, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, SOURCE, PARAMS, CMC_EVAL PARTS)
|
||||
#define C_MACRO_COLLECTIONS_EXTENDED_SOURCE(LIB, COLLECTION, ACCESS, PARAMS, PARTS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE, ACCESS, SOURCE, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, ACCESS, SOURCE, PARAMS, CMC_EVAL PARTS)
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_ALL
|
||||
@@ -146,11 +192,11 @@
|
||||
*
|
||||
* \param LIB The collection's library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_ALL(LIB, COLLECTION, PARAMS) \
|
||||
C_MACRO_COLLECTIONS_ALL_HEADER(LIB, COLLECTION, PARAMS) \
|
||||
C_MACRO_COLLECTIONS_ALL_SOURCE(LIB, COLLECTION, PARAMS)
|
||||
C_MACRO_COLLECTIONS_ALL_HEADER(LIB, COLLECTION, PUBLIC, PARAMS) \
|
||||
C_MACRO_COLLECTIONS_ALL_SOURCE(LIB, COLLECTION, PUBLIC, PARAMS)
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_ALL_HEADER
|
||||
@@ -159,11 +205,12 @@
|
||||
*
|
||||
* \param LIB The collection's library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_ALL_HEADER(LIB, COLLECTION, PARAMS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE_PUBLIC, HEADER, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, HEADER, PARAMS, C_MACRO_COLLECTIONS_PARTS(LIB, COLLECTION))
|
||||
#define C_MACRO_COLLECTIONS_ALL_HEADER(LIB, COLLECTION, ACCESS, PARAMS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE, ACCESS, HEADER, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, ACCESS, HEADER, PARAMS, C_MACRO_COLLECTIONS_PARTS(LIB, COLLECTION))
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_ALL_SOURCE
|
||||
@@ -172,11 +219,12 @@
|
||||
*
|
||||
* \param LIB The collection's library
|
||||
* \param COLLECTION The name of the collection in all uppercase
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V
|
||||
*/
|
||||
#define C_MACRO_COLLECTIONS_ALL_SOURCE(LIB, COLLECTION, PARAMS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE_PUBLIC, SOURCE, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, SOURCE, PARAMS, C_MACRO_COLLECTIONS_PARTS(LIB, COLLECTION))
|
||||
#define C_MACRO_COLLECTIONS_ALL_SOURCE(LIB, COLLECTION, ACCESS, PARAMS) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, CORE, ACCESS, SOURCE, PARAMS) \
|
||||
CMC_MAP(CMC_(EXT_, LIB), COLLECTION, ACCESS, SOURCE, PARAMS, C_MACRO_COLLECTIONS_PARTS(LIB, COLLECTION))
|
||||
|
||||
/**
|
||||
* C_MACRO_COLLECTIONS_PARTS
|
||||
@@ -209,40 +257,37 @@
|
||||
7, 6, 5, 4, 3, 2, 1, 0
|
||||
|
||||
/* Generates the FILE for each part (__VA_ARGS__) of a collection */
|
||||
#define CMC_MAP(LIB, COLLECTION, FILE, PARAMS, ...) \
|
||||
#define CMC_MAP(LIB, COLLECTION, ACCESS, FILE, PARAMS, ...) \
|
||||
CMC_(CMC_MAP_, CMC_NARG(__VA_ARGS__)) \
|
||||
(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
|
||||
#define CMC_MAP_0(LIB, COLLECTION, FILE, PARAMS, PART, ...)
|
||||
#define CMC_MAP_1(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_0(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_2(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_1(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_3(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_2(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_4(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_3(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_5(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_4(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_6(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_5(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_7(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_6(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_8(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_7(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_9(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_8(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_10(LIB, COLLECTION, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, FILE, PARAMS) \
|
||||
CMC_MAP_9(LIB, COLLECTION, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_9(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_8(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_8(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_7(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_7(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_6(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_6(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_5(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_5(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_4(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_4(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_3(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_3(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_2(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_2(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_1(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_1(LIB, COLLECTION, ACCESS, FILE, PARAMS, PART, ...) \
|
||||
C_MACRO_COLLECTIONS(LIB, COLLECTION, PART, ACCESS, FILE, PARAMS) \
|
||||
CMC_MAP_0(LIB, COLLECTION, ACCESS, FILE, PARAMS, __VA_ARGS__)
|
||||
#define CMC_MAP_0(LIB, COLLECTION, ACCESS, FILE, PARAMS, ...)
|
||||
|
||||
#endif /* CMC_MACRO_COLLECTIONS_H */
|
||||
+534
@@ -0,0 +1,534 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* sac_list.h
|
||||
*
|
||||
* Creation Date: 06/10/2020
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* List
|
||||
*
|
||||
* A List that is stored in a fixed sized array. It works very much like a list
|
||||
* but is not resizeable and doesn't make use of dynamic memory internally.
|
||||
*/
|
||||
|
||||
/* TODO : Remove all allocations */
|
||||
|
||||
#ifndef CMC_SAC_LIST_H
|
||||
#define CMC_SAC_LIST_H
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Core functionalities of the C Macro Collections Library
|
||||
* ------------------------------------------------------------------------- */
|
||||
#include "cor_core.h"
|
||||
|
||||
/**
|
||||
* Core List implementation
|
||||
*
|
||||
* \param ACCESS Either PUBLIC or PRIVATE
|
||||
* \param FILE Either HEADER or SOURCE
|
||||
* \param PARAMS A tuple of form (PFX, SNAME, SIZE, K, V)
|
||||
*/
|
||||
#define CMC_SAC_LIST_CORE(ACCESS, FILE, PARAMS) CMC_(CMC_(CMC_SAC_LIST_CORE_, ACCESS), CMC_(_, FILE))(PARAMS)
|
||||
|
||||
/* PRIVATE or PUBLIC solver */
|
||||
#define CMC_SAC_LIST_CORE_PUBLIC_HEADER(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_STRUCT(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_HEADER(PARAMS)
|
||||
|
||||
#define CMC_SAC_LIST_CORE_PUBLIC_SOURCE(PARAMS) CMC_SAC_LIST_CORE_SOURCE(PARAMS)
|
||||
|
||||
#define CMC_SAC_LIST_CORE_PRIVATE_HEADER(PARAMS) \
|
||||
struct CMC_PARAM_SNAME(PARAMS); \
|
||||
CMC_SAC_LIST_CORE_HEADER(PARAMS)
|
||||
|
||||
#define CMC_SAC_LIST_CORE_PRIVATE_SOURCE(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_STRUCT(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_SOURCE(PARAMS)
|
||||
|
||||
/* Lowest level API */
|
||||
#define CMC_SAC_LIST_CORE_STRUCT(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_STRUCT_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SIZE(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_SAC_LIST_CORE_HEADER(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_HEADER_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SIZE(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
#define CMC_SAC_LIST_CORE_SOURCE(PARAMS) \
|
||||
CMC_SAC_LIST_CORE_SOURCE_(CMC_PARAM_PFX(PARAMS), CMC_PARAM_SIZE(PARAMS), CMC_PARAM_SNAME(PARAMS), CMC_PARAM_V(PARAMS))
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Struct
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define CMC_SAC_LIST_CORE_STRUCT_(PFX, SIZE, SNAME, V) \
|
||||
\
|
||||
/* List Structure */ \
|
||||
struct SNAME \
|
||||
{ \
|
||||
/* Dynamic array of elements */ \
|
||||
V buffer[SIZE]; \
|
||||
\
|
||||
/* Current amount of elements */ \
|
||||
size_t count; \
|
||||
\
|
||||
/* Flags indicating errors or success */ \
|
||||
int flag; \
|
||||
\
|
||||
/* Value function table */ \
|
||||
struct CMC_DEF_FVAL(SNAME) * f_val; \
|
||||
\
|
||||
/* Custom callback functions */ \
|
||||
CMC_CALLBACKS_DECL; \
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Header
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define CMC_SAC_LIST_CORE_HEADER_(PFX, SIZE, SNAME, V) \
|
||||
\
|
||||
/* Value struct function table */ \
|
||||
struct CMC_DEF_FVAL(SNAME) \
|
||||
{ \
|
||||
/* Comparator function */ \
|
||||
CMC_DEF_FTAB_CMP(V); \
|
||||
\
|
||||
/* Copy function */ \
|
||||
CMC_DEF_FTAB_CPY(V); \
|
||||
\
|
||||
/* To string function */ \
|
||||
CMC_DEF_FTAB_STR(V); \
|
||||
\
|
||||
/* Free from memory function */ \
|
||||
CMC_DEF_FTAB_FREE(V); \
|
||||
\
|
||||
/* Hash function */ \
|
||||
CMC_DEF_FTAB_HASH(V); \
|
||||
\
|
||||
/* Priority function */ \
|
||||
CMC_DEF_FTAB_PRI(V); \
|
||||
}; \
|
||||
\
|
||||
/* Collection Functions */ \
|
||||
/* Collection Allocation and Deallocation */ \
|
||||
struct SNAME CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val); \
|
||||
struct SNAME CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_CALLBACKS_NAME * callbacks); \
|
||||
void CMC_(PFX, _free)(struct SNAME * _list_); \
|
||||
/* Customization of Allocation and Callbacks */ \
|
||||
void CMC_(PFX, _customize)(struct SNAME * _list_, \
|
||||
struct CMC_CALLBACKS_NAME * callbacks); \
|
||||
/* Collection Input and Output */ \
|
||||
bool CMC_(PFX, _push_front)(struct SNAME * _list_, V value); \
|
||||
bool CMC_(PFX, _push_at)(struct SNAME * _list_, V value, size_t index); \
|
||||
bool CMC_(PFX, _push_back)(struct SNAME * _list_, V value); \
|
||||
bool CMC_(PFX, _pop_front)(struct SNAME * _list_); \
|
||||
bool CMC_(PFX, _pop_at)(struct SNAME * _list_, size_t index); \
|
||||
bool CMC_(PFX, _pop_back)(struct SNAME * _list_); \
|
||||
/* Element Access */ \
|
||||
V CMC_(PFX, _front)(struct SNAME * _list_); \
|
||||
V CMC_(PFX, _get)(struct SNAME * _list_, size_t index); \
|
||||
V *CMC_(PFX, _get_ref)(struct SNAME * _list_, size_t index); \
|
||||
V CMC_(PFX, _back)(struct SNAME * _list_); \
|
||||
size_t CMC_(PFX, _index_of)(struct SNAME * _list_, V value, bool from_start); \
|
||||
/* Collection State */ \
|
||||
bool CMC_(PFX, _contains)(struct SNAME * _list_, V value); \
|
||||
bool CMC_(PFX, _empty)(struct SNAME * _list_); \
|
||||
bool CMC_(PFX, _full)(struct SNAME * _list_); \
|
||||
size_t CMC_(PFX, _count)(struct SNAME * _list_); \
|
||||
bool CMC_(PFX, _fits)(struct SNAME * _list_, size_t size); \
|
||||
size_t CMC_(PFX, _capacity)(struct SNAME * _list_); \
|
||||
int CMC_(PFX, _flag)(struct SNAME * _list_); \
|
||||
/* Collection Utility */ \
|
||||
struct SNAME CMC_(PFX, _copy_of)(struct SNAME * _list_); \
|
||||
bool CMC_(PFX, _equals)(struct SNAME * _list1_, struct SNAME * _list2_);
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Source
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define CMC_SAC_LIST_CORE_SOURCE_(PFX, SIZE, SNAME, V) \
|
||||
\
|
||||
/* Implementation Detail Functions */ \
|
||||
/* None */ \
|
||||
\
|
||||
struct SNAME CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val) \
|
||||
{ \
|
||||
return CMC_(PFX, _new_custom)(f_val, NULL); \
|
||||
} \
|
||||
\
|
||||
struct SNAME CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_CALLBACKS_NAME * callbacks) \
|
||||
{ \
|
||||
CMC_CALLBACKS_MAYBE_UNUSED(callbacks); \
|
||||
\
|
||||
if (!f_val) \
|
||||
return (struct SNAME) { .flag = CMC_FLAG_ERROR, 0 }; \
|
||||
\
|
||||
struct SNAME _list_ = { 0 }; \
|
||||
\
|
||||
_list_.f_val = f_val; \
|
||||
CMC_CALLBACKS_ASSIGN(&_list_, callbacks); \
|
||||
\
|
||||
return _list_; \
|
||||
} \
|
||||
\
|
||||
void CMC_(PFX, _free)(struct SNAME * _list_) \
|
||||
{ \
|
||||
if (_list_->f_val->free) \
|
||||
{ \
|
||||
for (size_t i = 0; i < _list_->count; i++) \
|
||||
_list_->f_val->free(_list_->buffer[i]); \
|
||||
} \
|
||||
\
|
||||
memset(_list_, 0, sizeof(struct SNAME)); \
|
||||
} \
|
||||
\
|
||||
void CMC_(PFX, _customize)(struct SNAME * _list_, \
|
||||
struct CMC_CALLBACKS_NAME * callbacks) \
|
||||
{ \
|
||||
CMC_CALLBACKS_MAYBE_UNUSED(callbacks); \
|
||||
\
|
||||
CMC_CALLBACKS_ASSIGN(_list_, callbacks); \
|
||||
\
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _push_front)(struct SNAME * _list_, V value) \
|
||||
{ \
|
||||
if (CMC_(PFX, _full)(_list_)) \
|
||||
{\
|
||||
_list_->flag = CMC_FLAG_FULL;\
|
||||
return false; \
|
||||
}\
|
||||
\
|
||||
if (!CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
memmove(_list_->buffer + 1, _list_->buffer, _list_->count * sizeof(V)); \
|
||||
} \
|
||||
\
|
||||
_list_->buffer[0] = value; \
|
||||
\
|
||||
_list_->count++; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, create); \
|
||||
\
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _push_at)(struct SNAME * _list_, V value, size_t index) \
|
||||
{ \
|
||||
if (index > _list_->count) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_RANGE; \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
if (CMC_(PFX, _full)(_list_)) \
|
||||
{\
|
||||
_list_->flag = CMC_FLAG_FULL;\
|
||||
return false; \
|
||||
}\
|
||||
\
|
||||
memmove(_list_->buffer + index + 1, _list_->buffer + index, (_list_->count - index) * sizeof(V)); \
|
||||
\
|
||||
_list_->buffer[index] = value; \
|
||||
_list_->count++; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, create); \
|
||||
\
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _push_back)(struct SNAME * _list_, V value) \
|
||||
{ \
|
||||
if (CMC_(PFX, _full)(_list_)) \
|
||||
{\
|
||||
_list_->flag = CMC_FLAG_FULL;\
|
||||
return false; \
|
||||
}\
|
||||
\
|
||||
_list_->buffer[_list_->count++] = value; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, create); \
|
||||
\
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _pop_front)(struct SNAME * _list_) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
memmove(_list_->buffer, _list_->buffer + 1, (_list_->count - 1) * sizeof(V)); \
|
||||
\
|
||||
_list_->buffer[--_list_->count] = (V){ 0 }; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, delete); \
|
||||
\
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _pop_at)(struct SNAME * _list_, size_t index) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
if (index >= _list_->count) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_RANGE; \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
memmove(_list_->buffer + index, _list_->buffer + index + 1, (_list_->count - index - 1) * sizeof(V)); \
|
||||
\
|
||||
_list_->buffer[--_list_->count] = (V){ 0 }; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, delete); \
|
||||
\
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _pop_back)(struct SNAME * _list_) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{\
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return false; \
|
||||
}\
|
||||
\
|
||||
_list_->buffer[--_list_->count] = (V){ 0 }; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, delete); \
|
||||
\
|
||||
return true; \
|
||||
} \
|
||||
\
|
||||
V CMC_(PFX, _front)(struct SNAME * _list_) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return (V){ 0 }; \
|
||||
} \
|
||||
\
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, read); \
|
||||
\
|
||||
return _list_->buffer[0]; \
|
||||
} \
|
||||
\
|
||||
V CMC_(PFX, _get)(struct SNAME * _list_, size_t index) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return (V){ 0 }; \
|
||||
} \
|
||||
\
|
||||
if (index >= _list_->count) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_RANGE; \
|
||||
return (V){ 0 }; \
|
||||
} \
|
||||
\
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, read); \
|
||||
\
|
||||
return _list_->buffer[index]; \
|
||||
} \
|
||||
\
|
||||
V *CMC_(PFX, _get_ref)(struct SNAME * _list_, size_t index) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
if (index >= _list_->count) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_RANGE; \
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, read); \
|
||||
\
|
||||
return &(_list_->buffer[index]); \
|
||||
} \
|
||||
\
|
||||
V CMC_(PFX, _back)(struct SNAME * _list_) \
|
||||
{ \
|
||||
if (CMC_(PFX, _empty)(_list_)) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_EMPTY; \
|
||||
return (V){ 0 }; \
|
||||
} \
|
||||
\
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, read); \
|
||||
\
|
||||
return _list_->buffer[_list_->count - 1]; \
|
||||
} \
|
||||
\
|
||||
size_t CMC_(PFX, _index_of)(struct SNAME * _list_, V value, bool from_start) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
size_t result = _list_->count; \
|
||||
\
|
||||
if (from_start) \
|
||||
{ \
|
||||
for (size_t i = 0; i < _list_->count; i++) \
|
||||
{ \
|
||||
if (_list_->f_val->cmp(_list_->buffer[i], value) == 0) \
|
||||
{ \
|
||||
result = i; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
for (size_t i = _list_->count; i > 0; i--) \
|
||||
{ \
|
||||
if (_list_->f_val->cmp(_list_->buffer[i - 1], value) == 0) \
|
||||
{ \
|
||||
result = i - 1; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, read); \
|
||||
\
|
||||
return result; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _contains)(struct SNAME * _list_, V value) \
|
||||
{ \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
bool result = false; \
|
||||
\
|
||||
for (size_t i = 0; i < _list_->count; i++) \
|
||||
{ \
|
||||
if (_list_->f_val->cmp(_list_->buffer[i], value) == 0) \
|
||||
{ \
|
||||
result = true; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
CMC_CALLBACKS_CALL(_list_, read); \
|
||||
\
|
||||
return result; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _empty)(struct SNAME * _list_) \
|
||||
{ \
|
||||
return _list_->count == 0; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _full)(struct SNAME * _list_) \
|
||||
{ \
|
||||
return _list_->count >= SIZE; \
|
||||
} \
|
||||
\
|
||||
size_t CMC_(PFX, _count)(struct SNAME * _list_) \
|
||||
{ \
|
||||
return _list_->count; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _fits)(struct SNAME * _list_, size_t size) \
|
||||
{ \
|
||||
return _list_->count + size <= SIZE; \
|
||||
} \
|
||||
\
|
||||
size_t CMC_(PFX, _capacity)(struct SNAME * _list_) \
|
||||
{ \
|
||||
return SIZE; \
|
||||
} \
|
||||
\
|
||||
int CMC_(PFX, _flag)(struct SNAME * _list_) \
|
||||
{ \
|
||||
return _list_->flag; \
|
||||
} \
|
||||
\
|
||||
struct SNAME CMC_(PFX, _copy_of)(struct SNAME * _list_) \
|
||||
{ \
|
||||
struct SNAME result = CMC_(PFX, _new_custom)(_list_->f_val, NULL); \
|
||||
\
|
||||
CMC_CALLBACKS_ASSIGN(&result, _list_->callbacks); \
|
||||
\
|
||||
if (_list_->f_val->cpy) \
|
||||
{ \
|
||||
for (size_t i = 0; i < _list_->count; i++) \
|
||||
result.buffer[i] = _list_->f_val->cpy(_list_->buffer[i]); \
|
||||
} \
|
||||
else \
|
||||
memcpy(result.buffer, _list_->buffer, sizeof(V) * _list_->count); \
|
||||
\
|
||||
result.count = _list_->count; \
|
||||
_list_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
return result; \
|
||||
} \
|
||||
\
|
||||
bool CMC_(PFX, _equals)(struct SNAME * _list1_, struct SNAME * _list2_) \
|
||||
{ \
|
||||
_list1_->flag = CMC_FLAG_OK; \
|
||||
_list2_->flag = CMC_FLAG_OK; \
|
||||
\
|
||||
if (_list1_->count != _list2_->count) \
|
||||
return false; \
|
||||
\
|
||||
for (size_t i = 0; i < _list1_->count; i++) \
|
||||
{ \
|
||||
if (0 != _list1_->f_val->cmp(_list1_->buffer[i], _list2_->buffer[i])) \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
return true; \
|
||||
}
|
||||
|
||||
#endif /* CMC_SAC_LIST_H */
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* utl/foreach.h
|
||||
*
|
||||
* Creation Date: 25/02/2019
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* For-Each macros that work with all Collections within the library.
|
||||
*
|
||||
* PFX - Functions prefix
|
||||
* SNAME - Struct name
|
||||
* ITERNAME - Iterator variable name
|
||||
* TARGET - Target variable
|
||||
*/
|
||||
|
||||
#ifndef CMC_UTL_FOREACH_H
|
||||
#define CMC_UTL_FOREACH_H
|
||||
|
||||
#include "../cor/core.h"
|
||||
|
||||
#define CMC_FOREACH(PFX, SNAME, ITERNAME, TARGET) \
|
||||
for (struct CMC_DEF_ITER(SNAME) ITERNAME = CMC_(PFX, _iter_start)(TARGET); !CMC_(PFX, _iter_at_end)(&ITERNAME); \
|
||||
CMC_(PFX, _iter_next)(&ITERNAME))
|
||||
|
||||
#define CMC_FOREACH_REV(PFX, SNAME, ITERNAME, TARGET) \
|
||||
for (struct CMC_DEF_ITER(SNAME) ITERNAME = CMC_(PFX, _iter_end)(TARGET); !CMC_(PFX, _iter_at_start)(&ITERNAME); \
|
||||
CMC_(PFX, _iter_prev)(&ITERNAME))
|
||||
|
||||
#endif /* CMC_UTL_FOREACH_H */
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* utl/timer.h
|
||||
*
|
||||
* Creation Date: 12/04/2019
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple timer macros utility for timing code execution.
|
||||
*/
|
||||
|
||||
#ifndef CMC_UTL_TIMER_H
|
||||
#define CMC_UTL_TIMER_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct cmc_timer
|
||||
{
|
||||
clock_t start;
|
||||
clock_t stop;
|
||||
double result; /* The result is given in milliseconds */
|
||||
};
|
||||
|
||||
#define cmc_timer_start(timer) \
|
||||
do \
|
||||
{ \
|
||||
struct cmc_timer *t__ = &(timer); \
|
||||
t__->start = clock(); \
|
||||
} while (0)
|
||||
|
||||
#define cmc_timer_stop(timer) \
|
||||
do \
|
||||
{ \
|
||||
struct cmc_timer *t__ = &(timer); \
|
||||
t__->stop = clock(); \
|
||||
t__->result = (double)(t__->stop - t__->start) * 1000.0 / CLOCKS_PER_SEC; \
|
||||
} while (0)
|
||||
|
||||
#endif /* CMC_UTL_TIMER_H */
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* utl/assert.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_assert.h
|
||||
*
|
||||
* Creation Date: 27/06/2019
|
||||
*
|
||||
@@ -56,7 +80,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
#define CMC_ASSERT_GLUE_(dtype, assertion) cmc_assert_##assertion##_##dtype
|
||||
#define CMC_ASSERT_GLUE(dtype, assertion) CMC_ASSERT_GLUE_(dtype, assertion)
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_foreach.h
|
||||
*
|
||||
* Creation Date: 25/02/2019
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* For-Each macros that work with all Collections within the library.
|
||||
*
|
||||
* PFX - Functions prefix
|
||||
* SNAME - Struct name
|
||||
* ITERNAME - Iterator variable name
|
||||
* TARGET - Target variable
|
||||
*/
|
||||
|
||||
#ifndef CMC_UTL_FOREACH_H
|
||||
#define CMC_UTL_FOREACH_H
|
||||
|
||||
#include "cor_core.h"
|
||||
|
||||
#define CMC_FOREACH(PFX, SNAME, ITERNAME, TARGET) \
|
||||
for (struct CMC_DEF_ITER(SNAME) ITERNAME = CMC_(PFX, _iter_start)(TARGET); !CMC_(PFX, _iter_at_end)(&ITERNAME); \
|
||||
CMC_(PFX, _iter_next)(&ITERNAME))
|
||||
|
||||
#define CMC_FOREACH_REV(PFX, SNAME, ITERNAME, TARGET) \
|
||||
for (struct CMC_DEF_ITER(SNAME) ITERNAME = CMC_(PFX, _iter_end)(TARGET); !CMC_(PFX, _iter_at_start)(&ITERNAME); \
|
||||
CMC_(PFX, _iter_prev)(&ITERNAME))
|
||||
|
||||
#endif /* CMC_UTL_FOREACH_H */
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* utl/futils.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_futils.h
|
||||
*
|
||||
* Creation Date: 15/04/2020
|
||||
*
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* utl/log.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_log.h
|
||||
*
|
||||
* Creation Date: 21/06/2019
|
||||
*
|
||||
@@ -64,7 +88,7 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../cor/core.h"
|
||||
#include "cor_core.h"
|
||||
|
||||
static const char *cmc_log_names[] = { "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" };
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* utl/mutex.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_mutex.h
|
||||
*
|
||||
* Creation Date: 14/05/2020
|
||||
*
|
||||
@@ -27,7 +51,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../cor/flags.h"
|
||||
#include "cor_flags.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define CMC_MUTEX_WINDOWS
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* utl/test.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_test.h
|
||||
*
|
||||
* Creation Date: 26/06/2019
|
||||
*
|
||||
@@ -42,9 +66,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../cor/core.h"
|
||||
#include "assert.h"
|
||||
#include "timer.h"
|
||||
#include "cor_core.h"
|
||||
#include "utl_assert.h"
|
||||
#include "utl_timer.h"
|
||||
|
||||
struct cmc_test_info
|
||||
{
|
||||
@@ -1,5 +1,29 @@
|
||||
/**
|
||||
* utl/thread.h
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_thread.h
|
||||
*
|
||||
* Creation Date: 14/05/2020
|
||||
*
|
||||
@@ -26,7 +50,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../cor/flags.h"
|
||||
#include "cor_flags.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define CMC_THREAD_WINDOWS
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) 2019 Leonardo Vencovsky
|
||||
*
|
||||
* This file is part of the C Macro Collections Libray.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* utl_timer.h
|
||||
*
|
||||
* Creation Date: 12/04/2019
|
||||
*
|
||||
* Authors:
|
||||
* Leonardo Vencovsky (https://github.com/LeoVen)
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple timer macros utility for timing code execution.
|
||||
*/
|
||||
|
||||
#ifndef CMC_UTL_TIMER_H
|
||||
#define CMC_UTL_TIMER_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct cmc_timer
|
||||
{
|
||||
clock_t start;
|
||||
clock_t stop;
|
||||
double result; /* The result is given in milliseconds */
|
||||
};
|
||||
|
||||
#define cmc_timer_start(timer) \
|
||||
do \
|
||||
{ \
|
||||
struct cmc_timer *t__ = &(timer); \
|
||||
t__->start = clock(); \
|
||||
} while (0)
|
||||
|
||||
#define cmc_timer_stop(timer) \
|
||||
do \
|
||||
{ \
|
||||
struct cmc_timer *t__ = &(timer); \
|
||||
t__->stop = clock(); \
|
||||
t__->result = (double)(t__->stop - t__->start) * 1000.0 / CLOCKS_PER_SEC; \
|
||||
} while (0)
|
||||
|
||||
#endif /* CMC_UTL_TIMER_H */
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
// Specifically used for code coverage
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "macro_collections.h"
|
||||
|
||||
#include "tst_cmc_bitset.h"
|
||||
#include "tst_cmc_deque.h"
|
||||
#include "tst_cmc_hashbidimap.h"
|
||||
#include "tst_cmc_hashmap.h"
|
||||
#include "tst_cmc_hashmultimap.h"
|
||||
#include "tst_cmc_hashmultiset.h"
|
||||
#include "tst_cmc_hashset.h"
|
||||
#include "tst_cmc_heap.h"
|
||||
#include "tst_cmc_intervalheap.h"
|
||||
#include "tst_cmc_linkedlist.h"
|
||||
#include "tst_cmc_list.h"
|
||||
#include "tst_cmc_queue.h"
|
||||
#include "tst_cmc_sortedlist.h"
|
||||
#include "tst_cmc_stack.h"
|
||||
#include "tst_cmc_treemap.h"
|
||||
#include "tst_cmc_treeset.h"
|
||||
|
||||
#include "tst_cmc_bitset.c"
|
||||
#include "tst_cmc_deque.c"
|
||||
#include "tst_cmc_hashbidimap.c"
|
||||
#include "tst_cmc_hashmap.c"
|
||||
#include "tst_cmc_hashmultimap.c"
|
||||
#include "tst_cmc_hashmultiset.c"
|
||||
#include "tst_cmc_hashset.c"
|
||||
#include "tst_cmc_heap.c"
|
||||
#include "tst_cmc_intervalheap.c"
|
||||
#include "tst_cmc_linkedlist.c"
|
||||
#include "tst_cmc_list.c"
|
||||
#include "tst_cmc_queue.c"
|
||||
#include "tst_cmc_sortedlist.c"
|
||||
#include "tst_cmc_stack.c"
|
||||
#include "tst_cmc_treemap.c"
|
||||
#include "tst_cmc_treeset.c"
|
||||
|
||||
#include "unt_cmc_bitset.h"
|
||||
#include "unt_cmc_deque.h"
|
||||
#include "unt_cmc_hashbidimap.h"
|
||||
#include "unt_cmc_hashmap.h"
|
||||
#include "unt_cmc_hashmultimap.h"
|
||||
#include "unt_cmc_hashmultiset.h"
|
||||
#include "unt_cmc_hashset.h"
|
||||
#include "unt_cmc_heap.h"
|
||||
#include "unt_cmc_intervalheap.h"
|
||||
#include "unt_cmc_linkedlist.h"
|
||||
#include "unt_cmc_list.h"
|
||||
#include "unt_cmc_queue.h"
|
||||
#include "unt_cmc_sortedlist.h"
|
||||
#include "unt_cmc_stack.h"
|
||||
#include "unt_cmc_treemap.h"
|
||||
#include "unt_cmc_treeset.h"
|
||||
|
||||
#include "unt_utl_foreach.h"
|
||||
|
||||
#include "utl_assert.h"
|
||||
#include "utl_timer.h"
|
||||
|
||||
#include "utl.h"
|
||||
|
||||
#define cmc_run(unit, unit_fails, test_fails) \
|
||||
do \
|
||||
{ \
|
||||
uintmax_t f = unit(); \
|
||||
if (f != 0) \
|
||||
unit_fails += 1; \
|
||||
test_fails += f; \
|
||||
} while (0)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// clang-format off
|
||||
printf(" +---------------------------------------------------------------+\n");
|
||||
printf(" | C Macro Collections Library |\n");
|
||||
printf(" | |\n");
|
||||
printf(" | Code Coverage Suite |\n");
|
||||
printf(" | |\n");
|
||||
printf(" | https://github.com/LeoVen/C-Macro-Collections |\n");
|
||||
printf(" | Leonardo Vencovsky (leonardo.vencovsky@gmail.com) |\n");
|
||||
printf(" +---------------------------------------------------------------+\n\n");
|
||||
// clang-format on
|
||||
|
||||
struct cmc_timer timer;
|
||||
|
||||
cmc_timer_start(timer);
|
||||
uintmax_t tests = 0, units = 0;
|
||||
|
||||
cmc_run(CMCBitSet, units, tests);
|
||||
cmc_run(CMCBitSetIter, units, tests);
|
||||
cmc_run(CMCDeque, units, tests);
|
||||
cmc_run(CMCDequeIter, units, tests);
|
||||
cmc_run(CMCHashBidiMap, units, tests);
|
||||
cmc_run(CMCHashBidiMapIter, units, tests);
|
||||
cmc_run(CMCHashMap, units, tests);
|
||||
cmc_run(CMCHashMapIter, units, tests);
|
||||
cmc_run(CMCHashMultiMap, units, tests);
|
||||
cmc_run(CMCHashMultiMapIter, units, tests);
|
||||
cmc_run(CMCHashMultiSet, units, tests);
|
||||
cmc_run(CMCHashMultiSetIter, units, tests);
|
||||
cmc_run(CMCHashSet, units, tests);
|
||||
cmc_run(CMCHashSetIter, units, tests);
|
||||
cmc_run(CMCHeap, units, tests);
|
||||
cmc_run(CMCHeapIter, units, tests);
|
||||
cmc_run(CMCIntervalHeap, units, tests);
|
||||
cmc_run(CMCIntervalHeapIter, units, tests);
|
||||
cmc_run(CMCLinkedList, units, tests);
|
||||
cmc_run(CMCLinkedListIter, units, tests);
|
||||
cmc_run(CMCList, units, tests);
|
||||
cmc_run(CMCListIter, units, tests);
|
||||
cmc_run(CMCQueue, units, tests);
|
||||
cmc_run(CMCQueueIter, units, tests);
|
||||
cmc_run(CMCSortedList, units, tests);
|
||||
cmc_run(CMCSortedListIter, units, tests);
|
||||
cmc_run(CMCStack, units, tests);
|
||||
cmc_run(CMCStackIter, units, tests);
|
||||
cmc_run(CMCTreeMap, units, tests);
|
||||
cmc_run(CMCTreeMapIter, units, tests);
|
||||
cmc_run(CMCTreeSet, units, tests);
|
||||
cmc_run(CMCTreeSetIter, units, tests);
|
||||
|
||||
cmc_run(ForEach, units, tests);
|
||||
|
||||
cmc_timer_stop(timer);
|
||||
|
||||
printf(" +---------------------------------------------------------------+\n");
|
||||
printf(" | SUMMARY |\n");
|
||||
printf(" +---------------------------------------------------------------+\n");
|
||||
printf(" | Total Units Failed : %25" PRIuMAX " units |\n", units);
|
||||
printf(" | Total Tests Failed : %25" PRIuMAX " tests |\n", tests);
|
||||
printf(" | Total Asserts Failed : %25" PRIuMAX " asserts |\n", cmc_assert_failed);
|
||||
printf(" | Total Runtime : %25.0lf milliseconds |\n", timer.result);
|
||||
printf(" +---------------------------------------------------------------+\n");
|
||||
|
||||
return tests;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+20
-20
@@ -1,29 +1,29 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "unt/cmc/bitset.h"
|
||||
#include "unt/cmc/deque.h"
|
||||
#include "unt/cmc/hashbidimap.h"
|
||||
#include "unt/cmc/hashmap.h"
|
||||
#include "unt/cmc/hashmultimap.h"
|
||||
#include "unt/cmc/hashmultiset.h"
|
||||
#include "unt/cmc/hashset.h"
|
||||
#include "unt/cmc/heap.h"
|
||||
#include "unt/cmc/intervalheap.h"
|
||||
#include "unt/cmc/linkedlist.h"
|
||||
#include "unt/cmc/list.h"
|
||||
#include "unt/cmc/queue.h"
|
||||
#include "unt/cmc/sortedlist.h"
|
||||
#include "unt/cmc/stack.h"
|
||||
#include "unt/cmc/treemap.h"
|
||||
#include "unt/cmc/treeset.h"
|
||||
#include "unt_cmc_bitset.h"
|
||||
#include "unt_cmc_deque.h"
|
||||
#include "unt_cmc_hashbidimap.h"
|
||||
#include "unt_cmc_hashmap.h"
|
||||
#include "unt_cmc_hashmultimap.h"
|
||||
#include "unt_cmc_hashmultiset.h"
|
||||
#include "unt_cmc_hashset.h"
|
||||
#include "unt_cmc_heap.h"
|
||||
#include "unt_cmc_intervalheap.h"
|
||||
#include "unt_cmc_linkedlist.h"
|
||||
#include "unt_cmc_list.h"
|
||||
#include "unt_cmc_queue.h"
|
||||
#include "unt_cmc_sortedlist.h"
|
||||
#include "unt_cmc_stack.h"
|
||||
#include "unt_cmc_treemap.h"
|
||||
#include "unt_cmc_treeset.h"
|
||||
|
||||
#include "unt/utl/foreach.h"
|
||||
#include "unt_utl_foreach.h"
|
||||
|
||||
#include "utl/assert.h"
|
||||
#include "utl/timer.h"
|
||||
#include "utl_assert.h"
|
||||
#include "utl_timer.h"
|
||||
|
||||
#include "./unt/utl.h"
|
||||
#include "utl.h"
|
||||
|
||||
#define cmc_run(unit, unit_fails, test_fails) \
|
||||
do \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/bitset.h"
|
||||
#include "tst_cmc_bitset.h"
|
||||
|
||||
_Bool bs_impl_resize(struct bitset *_bitset_, size_t n_bits, _Bool do_resize);
|
||||
struct bitset *bs_new(size_t n_bits)
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/deque.h"
|
||||
#include "tst_cmc_deque.h"
|
||||
|
||||
struct deque *d_new(size_t capacity, struct deque_fval *f_val)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/hashbidimap.h"
|
||||
#include "tst_cmc_hashbidimap.h"
|
||||
|
||||
static struct hashbidimap_entry *hbm_impl_new_entry(struct hashbidimap *_map_, size_t key, size_t value);
|
||||
static struct hashbidimap_entry **hbm_impl_get_entry_by_key(struct hashbidimap *_map_, size_t key);
|
||||
@@ -177,7 +177,7 @@ _Bool hbm_update_val(struct hashbidimap *_map_, size_t key, size_t new_val)
|
||||
_map_->flag = CMC_FLAG_NOT_FOUND;
|
||||
return 0;
|
||||
}
|
||||
if (_map_->f_key->cmp(new_val, (*key_entry)->value) == 0)
|
||||
if (_map_->f_val->cmp(new_val, (*key_entry)->value) == 0)
|
||||
goto success;
|
||||
if (hbm_impl_get_entry_by_val(_map_, new_val) != ((void *)0))
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/hashmap.h"
|
||||
#include "tst_cmc_hashmap.h"
|
||||
|
||||
static struct hashmap_entry *hm_impl_get_entry(struct hashmap *_map_, size_t key);
|
||||
static size_t hm_impl_calculate_size(size_t required);
|
||||
@@ -201,23 +201,20 @@ _Bool hm_max(struct hashmap *_map_, size_t *key, size_t *value)
|
||||
_map_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t max_key = (size_t){ 0 };
|
||||
size_t max_val = (size_t){ 0 };
|
||||
size_t first = 0;
|
||||
for (; first < _map_->capacity; first++)
|
||||
{
|
||||
if (_map_->buffer[first].state == CMC_ES_FILLED)
|
||||
{
|
||||
max_key = _map_->buffer[first].key;
|
||||
max_val = _map_->buffer[first].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (size_t i = first + 1; i < _map_->capacity; i++)
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
if (_map_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (_map_->f_key->cmp(_map_->buffer[i].key, max_key) > 0)
|
||||
if (first)
|
||||
{
|
||||
max_key = _map_->buffer[i].key;
|
||||
max_val = _map_->buffer[i].value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_map_->f_key->cmp(_map_->buffer[i].key, max_key) > 0)
|
||||
{
|
||||
max_key = _map_->buffer[i].key;
|
||||
max_val = _map_->buffer[i].value;
|
||||
@@ -228,6 +225,7 @@ _Bool hm_max(struct hashmap *_map_, size_t *key, size_t *value)
|
||||
*key = max_key;
|
||||
if (value)
|
||||
*value = max_val;
|
||||
_map_->flag = CMC_FLAG_OK;
|
||||
if ((_map_)->callbacks && (_map_)->callbacks->read)
|
||||
(_map_)->callbacks->read();
|
||||
;
|
||||
@@ -240,23 +238,20 @@ _Bool hm_min(struct hashmap *_map_, size_t *key, size_t *value)
|
||||
_map_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t min_key = (size_t){ 0 };
|
||||
size_t min_val = (size_t){ 0 };
|
||||
size_t first = 0;
|
||||
for (; first < _map_->capacity; first++)
|
||||
{
|
||||
if (_map_->buffer[first].state == CMC_ES_FILLED)
|
||||
{
|
||||
min_key = _map_->buffer[first].key;
|
||||
min_val = _map_->buffer[first].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (size_t i = first + 1; i < _map_->capacity; i++)
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
if (_map_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (_map_->f_key->cmp(_map_->buffer[i].key, min_key) < 0)
|
||||
if (first)
|
||||
{
|
||||
min_key = _map_->buffer[i].key;
|
||||
min_val = _map_->buffer[i].value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_map_->f_key->cmp(_map_->buffer[i].key, min_key) < 0)
|
||||
{
|
||||
min_key = _map_->buffer[i].key;
|
||||
min_val = _map_->buffer[i].value;
|
||||
@@ -267,6 +262,7 @@ _Bool hm_min(struct hashmap *_map_, size_t *key, size_t *value)
|
||||
*key = min_key;
|
||||
if (value)
|
||||
*value = min_val;
|
||||
_map_->flag = CMC_FLAG_OK;
|
||||
if ((_map_)->callbacks && (_map_)->callbacks->read)
|
||||
(_map_)->callbacks->read();
|
||||
;
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/hashmultimap.h"
|
||||
#include "tst_cmc_hashmultimap.h"
|
||||
|
||||
struct hashmultimap_entry *hmm_impl_new_entry(struct hashmultimap *_map_, size_t key, size_t value);
|
||||
struct hashmultimap_entry *hmm_impl_get_entry(struct hashmultimap *_map_, size_t key);
|
||||
@@ -48,7 +48,7 @@ void hmm_clear(struct hashmultimap *_map_)
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
struct hashmultimap_entry *scan = _map_->buffer[i][0];
|
||||
while (scan != ((void *)0))
|
||||
while (scan)
|
||||
{
|
||||
struct hashmultimap_entry *next = scan->next;
|
||||
if (_map_->f_key->free)
|
||||
@@ -69,7 +69,7 @@ void hmm_free(struct hashmultimap *_map_)
|
||||
while (index < _map_->capacity)
|
||||
{
|
||||
struct hashmultimap_entry *scan = _map_->buffer[index][0];
|
||||
if (scan != ((void *)0))
|
||||
if (scan)
|
||||
{
|
||||
if (scan->next == ((void *)0) && scan->prev == ((void *)0))
|
||||
{
|
||||
@@ -81,7 +81,7 @@ void hmm_free(struct hashmultimap *_map_)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (scan != ((void *)0))
|
||||
while (scan)
|
||||
{
|
||||
struct hashmultimap_entry *tmp = scan;
|
||||
scan = scan->next;
|
||||
@@ -188,7 +188,7 @@ size_t hmm_update_all(struct hashmultimap *_map_, size_t key, size_t new_value,
|
||||
}
|
||||
}
|
||||
size_t index = 0;
|
||||
while (entry != ((void *)0))
|
||||
while (entry)
|
||||
{
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0)
|
||||
{
|
||||
@@ -239,7 +239,7 @@ _Bool hmm_remove(struct hashmultimap *_map_, size_t key, size_t *out_value)
|
||||
else
|
||||
{
|
||||
_Bool found = 0;
|
||||
while (entry != ((void *)0))
|
||||
while (entry)
|
||||
{
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0)
|
||||
{
|
||||
@@ -247,9 +247,9 @@ _Bool hmm_remove(struct hashmultimap *_map_, size_t key, size_t *out_value)
|
||||
*head = entry->next;
|
||||
if (*tail == entry)
|
||||
*tail = entry->prev;
|
||||
if (entry->prev != ((void *)0))
|
||||
if (entry->prev)
|
||||
entry->prev->next = entry->next;
|
||||
if (entry->next != ((void *)0))
|
||||
if (entry->next)
|
||||
entry->next->prev = entry->prev;
|
||||
if (out_value)
|
||||
*out_value = entry->value;
|
||||
@@ -316,7 +316,7 @@ size_t hmm_remove_all(struct hashmultimap *_map_, size_t key, size_t **out_value
|
||||
}
|
||||
else
|
||||
{
|
||||
while (entry != ((void *)0))
|
||||
while (entry)
|
||||
{
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0)
|
||||
{
|
||||
@@ -325,9 +325,9 @@ size_t hmm_remove_all(struct hashmultimap *_map_, size_t key, size_t **out_value
|
||||
if (*tail == entry)
|
||||
*tail = entry->prev;
|
||||
struct hashmultimap_entry *next = entry->next;
|
||||
if (entry->prev != ((void *)0))
|
||||
if (entry->prev)
|
||||
entry->prev->next = entry->next;
|
||||
if (entry->next != ((void *)0))
|
||||
if (entry->next)
|
||||
entry->next->prev = entry->prev;
|
||||
if (out_values)
|
||||
(*out_values)[index] = entry->value;
|
||||
@@ -353,23 +353,26 @@ _Bool hmm_max(struct hashmultimap *_map_, size_t *key, size_t *value)
|
||||
_map_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t max_key = (size_t){ 0 };
|
||||
size_t max_val = (size_t){ 0 };
|
||||
struct hashmultimap_iter iter = hmm_iter_start(_map_);
|
||||
for (; !hmm_iter_at_end(&iter); hmm_iter_next(&iter))
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
size_t result_key = hmm_iter_key(&iter);
|
||||
size_t result_value = hmm_iter_value(&iter);
|
||||
size_t index = hmm_iter_index(&iter);
|
||||
if (index == 0)
|
||||
struct hashmultimap_entry *scan = _map_->buffer[i][0];
|
||||
while (scan)
|
||||
{
|
||||
max_key = result_key;
|
||||
max_val = result_value;
|
||||
}
|
||||
else if (_map_->f_key->cmp(result_key, max_key) > 0)
|
||||
{
|
||||
max_key = result_key;
|
||||
max_val = result_value;
|
||||
if (first)
|
||||
{
|
||||
max_key = scan->key;
|
||||
max_val = scan->value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_map_->f_key->cmp(scan->key, max_key) > 0)
|
||||
{
|
||||
max_key = scan->key;
|
||||
max_val = scan->value;
|
||||
}
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
if (key)
|
||||
@@ -389,23 +392,26 @@ _Bool hmm_min(struct hashmultimap *_map_, size_t *key, size_t *value)
|
||||
_map_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t min_key = (size_t){ 0 };
|
||||
size_t min_val = (size_t){ 0 };
|
||||
struct hashmultimap_iter iter = hmm_iter_start(_map_);
|
||||
for (; !hmm_iter_at_end(&iter); hmm_iter_next(&iter))
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
size_t result_key = hmm_iter_key(&iter);
|
||||
size_t result_value = hmm_iter_value(&iter);
|
||||
size_t index = hmm_iter_index(&iter);
|
||||
if (index == 0)
|
||||
struct hashmultimap_entry *scan = _map_->buffer[i][0];
|
||||
while (scan)
|
||||
{
|
||||
min_key = result_key;
|
||||
min_val = result_value;
|
||||
}
|
||||
else if (_map_->f_key->cmp(result_key, min_key) < 0)
|
||||
{
|
||||
min_key = result_key;
|
||||
min_val = result_value;
|
||||
if (first)
|
||||
{
|
||||
min_key = scan->key;
|
||||
min_val = scan->value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_map_->f_key->cmp(scan->key, min_key) < 0)
|
||||
{
|
||||
min_key = scan->key;
|
||||
min_val = scan->value;
|
||||
}
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
if (key)
|
||||
@@ -518,12 +524,14 @@ _Bool hmm_resize(struct hashmultimap *_map_, size_t capacity)
|
||||
_map_->flag = CMC_FLAG_ALLOC;
|
||||
return 0;
|
||||
}
|
||||
struct hashmultimap_iter iter = hmm_iter_start(_map_);
|
||||
for (; !hmm_iter_at_end(&iter); hmm_iter_next(&iter))
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
size_t key = hmm_iter_key(&iter);
|
||||
size_t value = hmm_iter_value(&iter);
|
||||
hmm_insert(_new_map_, key, value);
|
||||
struct hashmultimap_entry *scan = _map_->buffer[i][0];
|
||||
while (scan)
|
||||
{
|
||||
hmm_insert(_new_map_, scan->key, scan->value);
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
if (_map_->count != _new_map_->count)
|
||||
{
|
||||
@@ -555,18 +563,23 @@ struct hashmultimap *hmm_copy_of(struct hashmultimap *_map_)
|
||||
_map_->flag = CMC_FLAG_ERROR;
|
||||
return ((void *)0);
|
||||
}
|
||||
struct hashmultimap_iter iter = hmm_iter_start(_map_);
|
||||
if (!hmm_empty(_map_))
|
||||
for (size_t i = 0; i < _map_->capacity; i++)
|
||||
{
|
||||
for (; !hmm_iter_at_end(&iter); hmm_iter_next(&iter))
|
||||
struct hashmultimap_entry *scan = _map_->buffer[i][0];
|
||||
while (scan)
|
||||
{
|
||||
size_t key = hmm_iter_key(&iter);
|
||||
size_t value = hmm_iter_value(&iter);
|
||||
size_t key;
|
||||
size_t value;
|
||||
if (_map_->f_key->cpy)
|
||||
key = _map_->f_key->cpy(key);
|
||||
key = _map_->f_key->cpy(scan->key);
|
||||
else
|
||||
key = scan->key;
|
||||
if (_map_->f_val->cpy)
|
||||
value = _map_->f_val->cpy(value);
|
||||
value = _map_->f_val->cpy(scan->value);
|
||||
else
|
||||
value = scan->value;
|
||||
hmm_insert(result, key, value);
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
(result)->callbacks = _map_->callbacks;
|
||||
@@ -579,12 +592,19 @@ _Bool hmm_equals(struct hashmultimap *_map1_, struct hashmultimap *_map2_)
|
||||
_map2_->flag = CMC_FLAG_OK;
|
||||
if (_map1_->count != _map2_->count)
|
||||
return 0;
|
||||
struct hashmultimap_iter iter = hmm_iter_start(_map1_);
|
||||
for (; !hmm_iter_at_end(&iter); hmm_iter_next(&iter))
|
||||
struct hashmultimap *_map_a_;
|
||||
struct hashmultimap *_map_b_;
|
||||
_map_a_ = _map1_->capacity < _map2_->capacity ? _map1_ : _map2_;
|
||||
_map_b_ = _map_a_ == _map1_ ? _map2_ : _map1_;
|
||||
for (size_t i = 0; i < _map_a_->capacity; i++)
|
||||
{
|
||||
size_t key = hmm_iter_key(&iter);
|
||||
if (hmm_impl_key_count(_map1_, key) != hmm_impl_key_count(_map2_, key))
|
||||
return 0;
|
||||
struct hashmultimap_entry *scan = _map_a_->buffer[i][0];
|
||||
while (scan)
|
||||
{
|
||||
if (hmm_impl_key_count(_map_a_, scan->key) != hmm_impl_key_count(_map_b_, scan->key))
|
||||
return 0;
|
||||
scan = scan->next;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -603,7 +623,7 @@ struct hashmultimap_entry *hmm_impl_get_entry(struct hashmultimap *_map_, size_t
|
||||
{
|
||||
size_t hash = _map_->f_key->hash(key);
|
||||
struct hashmultimap_entry *entry = _map_->buffer[hash % _map_->capacity][0];
|
||||
while (entry != ((void *)0))
|
||||
while (entry)
|
||||
{
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0)
|
||||
return entry;
|
||||
@@ -618,7 +638,7 @@ size_t hmm_impl_key_count(struct hashmultimap *_map_, size_t key)
|
||||
size_t total_count = 0;
|
||||
if (!entry)
|
||||
return total_count;
|
||||
while (entry != ((void *)0))
|
||||
while (entry)
|
||||
{
|
||||
if (_map_->f_key->cmp(entry->key, key) == 0)
|
||||
total_count++;
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/hashmultiset.h"
|
||||
#include "tst_cmc_hashmultiset.h"
|
||||
|
||||
static size_t hms_impl_multiplicity_of(struct hashmultiset *_set_, size_t value);
|
||||
static struct hashmultiset_entry *hms_impl_insert_and_return(struct hashmultiset *_set_, size_t value, _Bool *new_node);
|
||||
@@ -218,16 +218,22 @@ _Bool hms_max(struct hashmultiset *_set_, size_t *value)
|
||||
_set_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t max_val = (size_t){ 0 };
|
||||
struct hashmultiset_iter iter = hms_iter_start(_set_);
|
||||
for (; !hms_iter_at_end(&iter); hms_iter_next(&iter))
|
||||
for (size_t i = 0; i < _set_->capacity; i++)
|
||||
{
|
||||
size_t result = hms_iter_value(&iter);
|
||||
size_t index = hms_iter_index(&iter);
|
||||
if (index == 0)
|
||||
max_val = result;
|
||||
else if (_set_->f_val->cmp(result, max_val) > 0)
|
||||
max_val = result;
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
max_val = _set_->buffer[i].value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, max_val) > 0)
|
||||
{
|
||||
max_val = _set_->buffer[i].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
*value = max_val;
|
||||
@@ -244,16 +250,22 @@ _Bool hms_min(struct hashmultiset *_set_, size_t *value)
|
||||
_set_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t min_val = (size_t){ 0 };
|
||||
struct hashmultiset_iter iter = hms_iter_start(_set_);
|
||||
for (; !hms_iter_at_end(&iter); hms_iter_next(&iter))
|
||||
for (size_t i = 0; i < _set_->capacity; i++)
|
||||
{
|
||||
size_t result = hms_iter_value(&iter);
|
||||
size_t index = hms_iter_index(&iter);
|
||||
if (index == 0)
|
||||
min_val = result;
|
||||
else if (_set_->f_val->cmp(result, min_val) < 0)
|
||||
min_val = result;
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
min_val = _set_->buffer[i].value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, min_val) < 0)
|
||||
{
|
||||
min_val = _set_->buffer[i].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
*value = min_val;
|
||||
@@ -335,10 +347,15 @@ _Bool hms_resize(struct hashmultiset *_set_, size_t capacity)
|
||||
_set_->flag = CMC_FLAG_ERROR;
|
||||
return 0;
|
||||
}
|
||||
struct hashmultiset_iter iter = hms_iter_start(_set_);
|
||||
for (; !hms_iter_at_end(&iter); hms_iter_next(&iter))
|
||||
for (size_t i = 0; i < _set_->capacity; i++)
|
||||
{
|
||||
hms_insert_many(_new_set_, hms_iter_value(&iter), hms_iter_multiplicity(&iter));
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
size_t value = _set_->buffer[i].value;
|
||||
size_t multiplicity = _set_->buffer[i].multiplicity;
|
||||
struct hashmultiset_entry *entry = hms_impl_insert_and_return(_new_set_, value, ((void *)0));
|
||||
entry->multiplicity = multiplicity;
|
||||
}
|
||||
}
|
||||
if (_set_->count != _new_set_->count)
|
||||
{
|
||||
@@ -407,14 +424,21 @@ _Bool hms_equals(struct hashmultiset *_set1_, struct hashmultiset *_set2_)
|
||||
return 0;
|
||||
if (_set1_->count == 0)
|
||||
return 1;
|
||||
struct hashmultiset_iter iter = hms_iter_start(_set1_);
|
||||
for (; !hms_iter_at_end(&iter); hms_iter_next(&iter))
|
||||
struct hashmultiset *_set_a_;
|
||||
struct hashmultiset *_set_b_;
|
||||
_set_a_ = _set1_->capacity < _set2_->capacity ? _set1_ : _set2_;
|
||||
_set_b_ = _set_a_ == _set1_ ? _set2_ : _set1_;
|
||||
for (size_t i = 0; i < _set_a_->capacity; i++)
|
||||
{
|
||||
struct hashmultiset_entry *entry = hms_impl_get_entry(_set2_, hms_iter_value(&iter));
|
||||
if (!entry)
|
||||
return 0;
|
||||
if (entry->multiplicity != hms_iter_multiplicity(&iter))
|
||||
return 0;
|
||||
if (_set_a_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
struct hashmultiset_entry *entry_a = &(_set_a_->buffer[i]);
|
||||
struct hashmultiset_entry *entry_b = hms_impl_get_entry(_set_b_, entry_a->value);
|
||||
if (!entry_b)
|
||||
return 0;
|
||||
if (entry_a->multiplicity != entry_b->multiplicity)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -427,11 +451,13 @@ static size_t hms_impl_multiplicity_of(struct hashmultiset *_set_, size_t value)
|
||||
}
|
||||
static struct hashmultiset_entry *hms_impl_insert_and_return(struct hashmultiset *_set_, size_t value, _Bool *new_node)
|
||||
{
|
||||
*new_node = 0;
|
||||
if (new_node)
|
||||
*new_node = 0;
|
||||
struct hashmultiset_entry *entry = hms_impl_get_entry(_set_, value);
|
||||
if (entry != ((void *)0))
|
||||
return entry;
|
||||
*new_node = 1;
|
||||
if (new_node)
|
||||
*new_node = 1;
|
||||
if (hms_full(_set_))
|
||||
{
|
||||
if (!hms_resize(_set_, _set_->capacity + 1))
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/hashset.h"
|
||||
#include "tst_cmc_hashset.h"
|
||||
|
||||
static struct hashset_entry *hs_impl_get_entry(struct hashset *_set_, size_t value);
|
||||
static size_t hs_impl_calculate_size(size_t required);
|
||||
@@ -164,16 +164,22 @@ _Bool hs_max(struct hashset *_set_, size_t *value)
|
||||
_set_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t max_val = (size_t){ 0 };
|
||||
struct hashset_iter iter = hs_iter_start(_set_);
|
||||
for (; !hs_iter_at_end(&iter); hs_iter_next(&iter))
|
||||
for (size_t i = 0; i < _set_->capacity; i++)
|
||||
{
|
||||
size_t result = hs_iter_value(&iter);
|
||||
size_t index = hs_iter_index(&iter);
|
||||
if (index == 0)
|
||||
max_val = result;
|
||||
else if (_set_->f_val->cmp(result, max_val) > 0)
|
||||
max_val = result;
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
max_val = _set_->buffer[i].value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, max_val) > 0)
|
||||
{
|
||||
max_val = _set_->buffer[i].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
*value = max_val;
|
||||
@@ -190,16 +196,22 @@ _Bool hs_min(struct hashset *_set_, size_t *value)
|
||||
_set_->flag = CMC_FLAG_EMPTY;
|
||||
return 0;
|
||||
}
|
||||
_Bool first = 1;
|
||||
size_t min_val = (size_t){ 0 };
|
||||
struct hashset_iter iter = hs_iter_start(_set_);
|
||||
for (; !hs_iter_at_end(&iter); hs_iter_next(&iter))
|
||||
for (size_t i = 0; i < _set_->capacity; i++)
|
||||
{
|
||||
size_t result = hs_iter_value(&iter);
|
||||
size_t index = hs_iter_index(&iter);
|
||||
if (index == 0)
|
||||
min_val = result;
|
||||
else if (_set_->f_val->cmp(result, min_val) < 0)
|
||||
min_val = result;
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
min_val = _set_->buffer[i].value;
|
||||
first = 0;
|
||||
}
|
||||
else if (_set_->f_val->cmp(_set_->buffer[i].value, min_val) < 0)
|
||||
{
|
||||
min_val = _set_->buffer[i].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
*value = min_val;
|
||||
@@ -266,11 +278,13 @@ _Bool hs_resize(struct hashset *_set_, size_t capacity)
|
||||
_set_->flag = CMC_FLAG_ALLOC;
|
||||
return 0;
|
||||
}
|
||||
struct hashset_iter iter = hs_iter_start(_set_);
|
||||
for (; !hs_iter_at_end(&iter); hs_iter_next(&iter))
|
||||
for (size_t i = 0; i < _set_->capacity; i++)
|
||||
{
|
||||
size_t value = hs_iter_value(&iter);
|
||||
hs_insert(_new_set_, value);
|
||||
if (_set_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
size_t value = _set_->buffer[i].value;
|
||||
hs_insert(_new_set_, value);
|
||||
}
|
||||
}
|
||||
if (_set_->count != _new_set_->count)
|
||||
{
|
||||
@@ -333,13 +347,17 @@ _Bool hs_equals(struct hashset *_set1_, struct hashset *_set2_)
|
||||
_set2_->flag = CMC_FLAG_OK;
|
||||
if (_set1_->count != _set2_->count)
|
||||
return 0;
|
||||
if (_set1_->count == 0)
|
||||
return 1;
|
||||
struct hashset_iter iter = hs_iter_start(_set1_);
|
||||
for (; !hs_iter_at_end(&iter); hs_iter_next(&iter))
|
||||
struct hashset *_set_a_;
|
||||
struct hashset *_set_b_;
|
||||
_set_a_ = _set1_->capacity < _set2_->capacity ? _set1_ : _set2_;
|
||||
_set_b_ = _set_a_ == _set1_ ? _set2_ : _set1_;
|
||||
for (size_t i = 0; i < _set_a_->capacity; i++)
|
||||
{
|
||||
if (hs_impl_get_entry(_set2_, hs_iter_value(&iter)) == ((void *)0))
|
||||
return 0;
|
||||
if (_set_a_->buffer[i].state == CMC_ES_FILLED)
|
||||
{
|
||||
if (!hs_impl_get_entry(_set_b_, _set_a_->buffer[i].value))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/heap.h"
|
||||
#include "tst_cmc_heap.h"
|
||||
|
||||
static void h_impl_float_up(struct heap *_heap_, size_t index);
|
||||
static void h_impl_float_down(struct heap *_heap_, size_t index);
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/intervalheap.h"
|
||||
#include "tst_cmc_intervalheap.h"
|
||||
|
||||
static void ih_impl_float_up_max(struct intervalheap *_heap_);
|
||||
static void ih_impl_float_up_min(struct intervalheap *_heap_);
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/linkedlist.h"
|
||||
#include "tst_cmc_linkedlist.h"
|
||||
|
||||
struct linkedlist *ll_new(struct linkedlist_fval *f_val)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/list.h"
|
||||
#include "tst_cmc_list.h"
|
||||
|
||||
struct list *l_new(size_t capacity, struct list_fval *f_val)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/queue.h"
|
||||
#include "tst_cmc_queue.h"
|
||||
|
||||
struct queue *q_new(size_t capacity, struct queue_fval *f_val)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/sortedlist.h"
|
||||
#include "tst_cmc_sortedlist.h"
|
||||
|
||||
static size_t sl_impl_binary_search_first(struct sortedlist *_list_, size_t value);
|
||||
static size_t sl_impl_binary_search_last(struct sortedlist *_list_, size_t value);
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/stack.h"
|
||||
#include "tst_cmc_stack.h"
|
||||
|
||||
struct stack *s_new(size_t capacity, struct stack_fval *f_val)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/treemap.h"
|
||||
#include "tst_cmc_treemap.h"
|
||||
|
||||
static struct treemap_node *tm_impl_new_node(struct treemap *_map_, size_t key, size_t value);
|
||||
static struct treemap_node *tm_impl_get_node(struct treemap *_map_, size_t key);
|
||||
@@ -400,19 +400,45 @@ struct treemap *tm_copy_of(struct treemap *_map_)
|
||||
_map_->flag = CMC_FLAG_ERROR;
|
||||
return ((void *)0);
|
||||
}
|
||||
struct treemap_iter iter = tm_iter_start(_map_);
|
||||
for (; !tm_iter_at_end(&iter); tm_iter_next(&iter))
|
||||
struct treemap_node *root = _map_->root;
|
||||
_Bool left_done = 0;
|
||||
while (root)
|
||||
{
|
||||
size_t key = tm_iter_key(&iter);
|
||||
size_t value = tm_iter_value(&iter);
|
||||
if (!left_done)
|
||||
{
|
||||
while (root->left)
|
||||
root = root->left;
|
||||
}
|
||||
size_t key;
|
||||
size_t value;
|
||||
if (_map_->f_key->cpy)
|
||||
key = _map_->f_key->cpy(key);
|
||||
key = _map_->f_key->cpy(root->key);
|
||||
else
|
||||
key = root->key;
|
||||
if (_map_->f_val->cpy)
|
||||
value = _map_->f_val->cpy(value);
|
||||
value = _map_->f_val->cpy(root->value);
|
||||
else
|
||||
value = root->value;
|
||||
tm_insert(result, key, value);
|
||||
left_done = 1;
|
||||
if (root->right)
|
||||
{
|
||||
left_done = 0;
|
||||
root = root->right;
|
||||
}
|
||||
else if (root->parent)
|
||||
{
|
||||
while (root->parent && root == root->parent->right)
|
||||
root = root->parent;
|
||||
if (!root->parent)
|
||||
break;
|
||||
root = root->parent;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
(result)->callbacks = _map_->callbacks;
|
||||
_map_->flag = CMC_FLAG_OK;
|
||||
(result)->callbacks = _map_->callbacks;
|
||||
return result;
|
||||
}
|
||||
_Bool tm_equals(struct treemap *_map1_, struct treemap *_map2_)
|
||||
@@ -421,14 +447,36 @@ _Bool tm_equals(struct treemap *_map1_, struct treemap *_map2_)
|
||||
_map2_->flag = CMC_FLAG_OK;
|
||||
if (_map1_->count != _map2_->count)
|
||||
return 0;
|
||||
struct treemap_iter iter = tm_iter_start(_map1_);
|
||||
for (; !tm_iter_at_end(&iter); tm_iter_next(&iter))
|
||||
struct treemap_node *root = _map1_->root;
|
||||
_Bool left_done = 0;
|
||||
while (root)
|
||||
{
|
||||
struct treemap_node *node = tm_impl_get_node(_map2_, tm_iter_key(&iter));
|
||||
if (!left_done)
|
||||
{
|
||||
while (root->left)
|
||||
root = root->left;
|
||||
}
|
||||
struct treemap_node *node = tm_impl_get_node(_map2_, root->key);
|
||||
if (node == ((void *)0))
|
||||
return 0;
|
||||
if (_map1_->f_val->cmp(node->value, tm_iter_value(&iter)) != 0)
|
||||
if (_map1_->f_val->cmp(node->value, root->value) != 0)
|
||||
return 0;
|
||||
left_done = 1;
|
||||
if (root->right)
|
||||
{
|
||||
left_done = 0;
|
||||
root = root->right;
|
||||
}
|
||||
else if (root->parent)
|
||||
{
|
||||
while (root->parent && root == root->parent->right)
|
||||
root = root->parent;
|
||||
if (!root->parent)
|
||||
break;
|
||||
root = root->parent;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "cmc/treeset.h"
|
||||
#include "tst_cmc_treeset.h"
|
||||
|
||||
static struct treeset_node *ts_impl_new_node(struct treeset *_set_, size_t value);
|
||||
static struct treeset_node *ts_impl_get_node(struct treeset *_set_, size_t value);
|
||||
Loaded 100 of 118 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user