12 Commits
Author SHA1 Message Date
Leonardo Vencovsky 99f08e2b6e Add clangd to project 2024-06-26 22:50:15 +02:00
Leonardo Vencovsky 47ece66520 Move everything out of src folder 2023-12-13 15:14:46 +01:00
Leonardo Vencovsky 2c1eb41280 Quickfix flags 2023-12-11 02:31:30 +01:00
Leonardo Vencovsky 53960a3bce List stabilization part 2 2023-12-10 20:44:17 +01:00
Leonardo Vencovsky e4dbeae46d List stabilization part 1 2023-12-10 20:44:17 +01:00
Leonardo Vencovsky 32deb8356c Add install dev deps target 2023-08-28 09:09:01 +02:00
Leonardo Vencovsky 3593957bb8 add phony targets 2023-08-21 08:56:45 +02:00
Leonardo Vencovsky a8735889c7 Quickfix for ALLOC_NODE 2023-03-09 16:51:48 +01:00
Leonardo Vencovsky 655b7fa825 Added FTABLE flag 2023-03-03 21:28:04 +01:00
Leonardo Vencovsky 78fe5c2b09 Libray 2023-02-28 16:42:49 +01:00
Leonardo Vencovsky 015d14216f Callbacks redone 2023-02-28 16:42:02 +01:00
Leonardo Vencovsky a46ba1f255 Add CNAME 2023-02-24 11:15:45 +01:00
156 changed files with 634 additions and 1815 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: "cmake"
+2
View File
@@ -62,3 +62,5 @@ build
tests/coverage tests/coverage
tests/out tests/out
cmake
+18
View File
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.8)
project(cmc)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
file(GLOB_RECURSE sources
"./tests/main.c"
)
add_definitions(-DCMC_CALLBACKS)
add_executable(cmc ${sources})
target_include_directories(cmc PUBLIC
"./"
)
+10
View File
@@ -8,6 +8,7 @@ help:
@echo - bench: runs benchmarks @echo - bench: runs benchmarks
@echo - docbuild: builds documentation to ./docs @echo - docbuild: builds documentation to ./docs
@echo - docserve: serves mdbook docs @echo - docserve: serves mdbook docs
@echo - install_dev_deps: install dev dependencies
tests: tests:
make -C ./tests make -C ./tests
@@ -26,3 +27,12 @@ docbuild:
docserve: docserve:
mdbook serve documentation mdbook serve documentation
install_dev_deps:
sudo apt install gcc make valgrind lcov clang-format hyperfine clangd cmake
cargo install mdbook
build_clangd:
cmake -S . -G "Unix Makefiles" -B cmake
.PHONY: tests tests_dev format bench docbuild docserve install_dev_deps
+5 -1
View File
@@ -1,7 +1,11 @@
CC=gcc CC=gcc
INCLUDE=-I ../src INCLUDE=-I ..
CFLAGS=-Wall -Wextra -Werror CFLAGS=-Wall -Wextra -Werror
benchmark: benchmark.c benchmark: benchmark.c
$(CC) $(CFLAGS) $(INCLUDE) $< -o ./$@.exe -lm $(CC) $(CFLAGS) $(INCLUDE) $< -o ./$@.exe -lm
./$@.exe ./$@.exe
clean:
rm *.exe -f
rm *.txt -f
+3 -2
View File
@@ -1,4 +1,4 @@
INCLUDE=-I ../../../src INCLUDE=-I ../../..
CFLAGS=-O3 -Wall -Wextra -Werror -DCOUNT=20000000 -DCMC_NO_CALLBACKS CFLAGS=-O3 -Wall -Wextra -Werror -DCOUNT=20000000 -DCMC_NO_CALLBACKS
# Install hyperfine # Install hyperfine
@@ -15,4 +15,5 @@ build:
g++ unorderedmap.cpp $(INCLUDE) -o unorderedmap.exe $(CFLAGS) g++ unorderedmap.cpp $(INCLUDE) -o unorderedmap.exe $(CFLAGS)
clean: clean:
rm *.exe rm *.exe -f
rm *.txt -f
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+14 -17
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -34,8 +34,7 @@ struct SNAME *CMC_(PFX, _new)(size_t n_bits)
return CMC_(PFX, _new_custom)(n_bits, NULL, NULL); return CMC_(PFX, _new_custom)(n_bits, NULL, NULL);
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -81,8 +80,7 @@ struct SNAME CMC_(PFX, _init)(size_t n_bits)
return CMC_(PFX, _init_custom)(n_bits, NULL, NULL); return CMC_(PFX, _init_custom)(n_bits, NULL, NULL);
} }
struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *CMC_UNUSED(callbacks))
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -132,8 +130,7 @@ void CMC_(PFX, _release)(struct SNAME _bitset_)
free(_bitset_.buffer); free(_bitset_.buffer);
} }
void CMC_(PFX, _customize)(struct SNAME *_bitset_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_bitset_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -169,7 +166,7 @@ bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, create); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -220,7 +217,7 @@ bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, create); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -243,7 +240,7 @@ bool CMC_(PFX, _clear)(struct SNAME *_bitset_, size_t bit_index)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, delete); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -294,7 +291,7 @@ bool CMC_(PFX, _clear_range)(struct SNAME *_bitset_, size_t from, size_t to)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, delete); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -317,7 +314,7 @@ bool CMC_(PFX, _flip)(struct SNAME *_bitset_, size_t bit_index)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, update); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -368,7 +365,7 @@ bool CMC_(PFX, _flip_range)(struct SNAME *_bitset_, size_t from, size_t to)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, update); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -408,7 +405,7 @@ bool CMC_(PFX, _set_all)(struct SNAME *_bitset_)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, create); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -424,7 +421,7 @@ bool CMC_(PFX, _clear_all)(struct SNAME *_bitset_)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, delete); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -440,7 +437,7 @@ bool CMC_(PFX, _flip_all)(struct SNAME *_bitset_)
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_bitset_, create); CMC_CALLBACKS_CALL(_bitset_);
return true; return true;
} }
@@ -507,7 +504,7 @@ bool CMC_(PFX, _impl_resize)(struct SNAME *_bitset_, size_t n_bits, bool do_resi
_bitset_->capacity = words; _bitset_->capacity = words;
CMC_CALLBACKS_CALL(_bitset_, resize); CMC_CALLBACKS_CALL(_bitset_);
_bitset_->flag = CMC_FLAG_OK; _bitset_->flag = CMC_FLAG_OK;
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -24,15 +24,12 @@
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t n_bits); struct SNAME *CMC_(PFX, _new)(size_t n_bits);
struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
struct SNAME CMC_(PFX, _init)(size_t n_bits); struct SNAME CMC_(PFX, _init)(size_t n_bits);
struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
void CMC_(PFX, _free)(struct SNAME *_bitset_); void CMC_(PFX, _free)(struct SNAME *_bitset_);
void CMC_(PFX, _release)(struct SNAME _bitset_); void CMC_(PFX, _release)(struct SNAME _bitset_);
void CMC_(PFX, _customize)(struct SNAME *_bitset_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_bitset_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index); bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index);
bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to); bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,7 @@ struct SNAME
/* Flags indicating errors or success */ /* Flags indicating errors or success */
int flag; int flag;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
+4 -2
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -44,7 +44,6 @@
#endif #endif
#include "core.h" #include "core.h"
/** /**
* struct cmc_alloc_node * struct cmc_alloc_node
* *
@@ -52,6 +51,9 @@
* functions. The cmc_alloc_node_default is the default heap allocator provided * functions. The cmc_alloc_node_default is the default heap allocator provided
* by the standard library. * by the standard library.
*/ */
#define CMC_ALLOC_TYPE struct CMC_ALLOC_NODE_NAME *
static struct CMC_ALLOC_NODE_NAME static struct CMC_ALLOC_NODE_NAME
{ {
void *(*malloc)(size_t); void *(*malloc)(size_t);
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+15 -37
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -35,49 +35,27 @@
#ifndef CMC_COR_CALLBACKS_H #ifndef CMC_COR_CALLBACKS_H
#define CMC_COR_CALLBACKS_H #define CMC_COR_CALLBACKS_H
#ifdef CMC_CAMEL_CASE typedef void (*cmc_callback)(const char func_name[], void *self);
#define CMC_CALLBACKS_NAME CMCCallbacks #define CMC_CALLBACK_TYPE cmc_callback
#else
#define CMC_CALLBACKS_NAME cmc_callbacks
#endif
#ifdef CMC_NO_CALLBACKS #ifdef CMC_CALLBACKS
#define CMC_CALLBACKS_DECL cmc_callback callbacks
#define CMC_CALLBACKS_MAYBE_UNUSED(param)
#define CMC_CALLBACKS_GET(ds) (ds)->callbacks
#define CMC_CALLBACKS_ASSIGN(ds, cb) CMC_CALLBACKS_GET(ds) = cb
#define CMC_CALLBACKS_CALL(ds) \
if (CMC_CALLBACKS_GET(ds)) \
CMC_CALLBACKS_GET(ds)(__func__, (void *)ds);
#else
#define CMC_CALLBACKS_DECL #define CMC_CALLBACKS_DECL
#define CMC_CALLBACKS_MAYBE_UNUSED(param) CMC_UNUSED_PARAM(param) /* Prevent -Wunused-parameter */ #define CMC_CALLBACKS_MAYBE_UNUSED(param) CMC_UNUSED_PARAM(param) /* Prevent -Wunused-parameter */
#define CMC_CALLBACKS_GET(ds) NULL /* Helps with compatibility */ #define CMC_CALLBACKS_GET(ds) NULL /* Helps with compatibility */
#define CMC_CALLBACKS_ASSIGN(ds, cb) #define CMC_CALLBACKS_ASSIGN(ds, cb)
#define CMC_CALLBACKS_CALL(ds, cb) #define CMC_CALLBACKS_CALL(ds)
#else
#define CMC_CALLBACKS_DECL struct CMC_CALLBACKS_NAME *callbacks
#define CMC_CALLBACKS_MAYBE_UNUSED(param)
#define CMC_CALLBACKS_GET(ds) (ds)->callbacks
#define CMC_CALLBACKS_ASSIGN(ds, cb) CMC_CALLBACKS_GET(ds) = cb
#define CMC_CALLBACKS_CALL(ds, cb) \
if (CMC_CALLBACKS_GET(ds) && CMC_CALLBACKS_GET(ds)->cb) \
CMC_CALLBACKS_GET(ds)->cb();
#endif #endif
/**
* struct cmc_callbacks
*
* Callback node. Each collection will call one of these functions when:
* - create : an element was successfully added to the collection
* - read : the collection was successfully queried about an element
* - update : an element in the collection was successfully updated
* - delete : an element was successfully removed from the collection
* - resize : the collection was full and successfully resized
*/
struct CMC_CALLBACKS_NAME
{
void (*create)(void);
void (*read)(void);
void (*update)(void);
void (*delete)(void);
void (*resize)(void);
};
#endif /* CMC_COR_CALLBACKS_H */ #endif /* CMC_COR_CALLBACKS_H */
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+3 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,6 +39,8 @@
* Macros for tracing and debugging data structures when CMC_DEV is enabled * Macros for tracing and debugging data structures when CMC_DEV is enabled
*/ */
#ifndef CMC_DEV_FCALL
#define CMC_DEV_FCALL cmc_log_trace("fcall") #define CMC_DEV_FCALL cmc_log_trace("fcall")
#endif
#endif /* CMC_COR_DEV_H */ #endif /* CMC_COR_DEV_H */
+5 -3
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -56,6 +56,7 @@ enum cmc_flags
CMC_FLAG_THREAD = 8, // Generic error regarding threads CMC_FLAG_THREAD = 8, // Generic error regarding threads
CMC_FLAG_MUTEX = 9, // Generic error regarding mutexes CMC_FLAG_MUTEX = 9, // Generic error regarding mutexes
CMC_FLAG_FULL = 10, // When a collection that doesn't resize is full CMC_FLAG_FULL = 10, // When a collection that doesn't resize is full
CMC_FLAG_FTABLE = 11, // When a required ftable function is missing
}; };
// clang-format on // clang-format on
@@ -64,7 +65,8 @@ enum cmc_flags
* *
* Maps the error codes to their character representation. * 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", CMC_UNUSED static const char *cmc_flags_to_str[12] = {
"DUPLICATE", "ERROR", "THREAD", "MUTEX", "FULL" }; "OK", "ALLOC", "EMPTY", "NOT_FOUND", "INVALID", "RANGE", "DUPLICATE", "ERROR", "THREAD", "MUTEX", "FULL", "FTABLE"
};
#endif /* CMC_COR_FLAGS_H */ #endif /* CMC_COR_FLAGS_H */
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+12 -13
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -34,8 +34,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL);
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -122,8 +122,7 @@ void CMC_(PFX, _free)(struct SNAME *_deque_)
_deque_->alloc->free(_deque_); _deque_->alloc->free(_deque_);
} }
void CMC_(PFX, _customize)(struct SNAME *_deque_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_deque_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -160,7 +159,7 @@ bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value)
_deque_->count++; _deque_->count++;
_deque_->flag = CMC_FLAG_OK; _deque_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_deque_, create); CMC_CALLBACKS_CALL(_deque_);
return true; return true;
} }
@@ -184,7 +183,7 @@ bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value)
_deque_->count++; _deque_->count++;
_deque_->flag = CMC_FLAG_OK; _deque_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_deque_, create); CMC_CALLBACKS_CALL(_deque_);
return true; return true;
} }
@@ -208,7 +207,7 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_deque_)
_deque_->count--; _deque_->count--;
_deque_->flag = CMC_FLAG_OK; _deque_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_deque_, delete); CMC_CALLBACKS_CALL(_deque_);
return true; return true;
} }
@@ -232,7 +231,7 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_deque_)
_deque_->count--; _deque_->count--;
_deque_->flag = CMC_FLAG_OK; _deque_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_deque_, delete); CMC_CALLBACKS_CALL(_deque_);
return true; return true;
} }
@@ -251,7 +250,7 @@ V CMC_(PFX, _front)(struct SNAME *_deque_)
_deque_->flag = CMC_FLAG_OK; _deque_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_deque_, read); CMC_CALLBACKS_CALL(_deque_);
return _deque_->buffer[_deque_->front]; return _deque_->buffer[_deque_->front];
} }
@@ -270,7 +269,7 @@ V CMC_(PFX, _back)(struct SNAME *_deque_)
_deque_->flag = CMC_FLAG_OK; _deque_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_deque_, read); CMC_CALLBACKS_CALL(_deque_);
return _deque_->buffer[(_deque_->back == 0) ? _deque_->capacity - 1 : _deque_->back - 1]; return _deque_->buffer[(_deque_->back == 0) ? _deque_->capacity - 1 : _deque_->back - 1];
} }
@@ -296,7 +295,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_deque_, V value)
i = (i + 1) % _deque_->capacity; i = (i + 1) % _deque_->capacity;
} }
CMC_CALLBACKS_CALL(_deque_, read); CMC_CALLBACKS_CALL(_deque_);
return result; return result;
} }
@@ -387,7 +386,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_deque_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_deque_, resize); CMC_CALLBACKS_CALL(_deque_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,8 +39,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL);
} }
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -31,8 +31,8 @@
#ifdef CMC_EXT_INIT #ifdef CMC_EXT_INIT
struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _release)(struct SNAME _deque_); void CMC_(PFX, _release)(struct SNAME _deque_);
#endif /* CMC_EXT_INIT */ #endif /* CMC_EXT_INIT */
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -41,13 +41,12 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_deque_); void CMC_(PFX, _clear)(struct SNAME *_deque_);
void CMC_(PFX, _free)(struct SNAME *_deque_); void CMC_(PFX, _free)(struct SNAME *_deque_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_deque_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_deque_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value); bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value);
bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value); bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ struct SNAME
/* Functions Table */ /* Functions Table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -43,8 +43,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -134,7 +134,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_)
_map_->alloc->free(_map_); _map_->alloc->free(_map_);
} }
void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -193,7 +193,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value)
_map_->count++; _map_->count++;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, create); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -260,7 +260,7 @@ success:
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, update); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -328,7 +328,7 @@ success:
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, update); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -377,7 +377,7 @@ bool CMC_(PFX, _remove_by_key)(struct SNAME *_map_, K key, K *out_key, V *out_va
_map_->count--; _map_->count--;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, delete); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -426,7 +426,7 @@ bool CMC_(PFX, _remove_by_val)(struct SNAME *_map_, V val, K *out_key, V *out_va
_map_->count--; _map_->count--;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, delete); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -447,7 +447,7 @@ K CMC_(PFX, _get_key)(struct SNAME *_map_, V val)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return (*entry)->key; return (*entry)->key;
} }
@@ -468,7 +468,7 @@ V CMC_(PFX, _get_val)(struct SNAME *_map_, K key)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return (*entry)->value; return (*entry)->value;
} }
@@ -483,7 +483,7 @@ bool CMC_(PFX, _contains_key)(struct SNAME *_map_, K key)
bool result = CMC_(PFX, _impl_get_entry_by_key)(_map_, key) != NULL; bool result = CMC_(PFX, _impl_get_entry_by_key)(_map_, key) != NULL;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return result; return result;
} }
@@ -498,7 +498,7 @@ bool CMC_(PFX, _contains_val)(struct SNAME *_map_, V val)
bool result = CMC_(PFX, _impl_get_entry_by_val)(_map_, val) != NULL; bool result = CMC_(PFX, _impl_get_entry_by_val)(_map_, val) != NULL;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return result; return result;
} }
@@ -649,7 +649,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_map_, resize); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -41,8 +41,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(
} }
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -33,8 +33,8 @@
struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val); struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _release)(struct SNAME _map_); void CMC_(PFX, _release)(struct SNAME _map_);
#endif /* CMC_EXT_INIT */ #endif /* CMC_EXT_INIT */
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -60,13 +60,12 @@ struct CMC_DEF_FVAL(SNAME)
struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val); struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _clear)(struct SNAME *_map_);
void CMC_(PFX, _free)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value);
bool CMC_(PFX, _update_key)(struct SNAME *_map_, V val, K new_key); bool CMC_(PFX, _update_key)(struct SNAME *_map_, V val, K new_key);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
/* Methods */ /* Methods */
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -33,8 +33,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -136,7 +136,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_)
_map_->alloc->free(_map_); _map_->alloc->free(_map_);
} }
void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -221,7 +221,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value)
_map_->count++; _map_->count++;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, create); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -253,7 +253,7 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, update); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -289,7 +289,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value)
_map_->count--; _map_->count--;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, delete); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -335,7 +335,7 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -381,7 +381,7 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -408,7 +408,7 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return entry->value; return entry->value;
} }
@@ -435,7 +435,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return &(entry->value); return &(entry->value);
} }
@@ -450,7 +450,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key)
bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL; bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return result; return result;
} }
@@ -587,7 +587,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_map_, resize); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -41,8 +41,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(
} }
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -33,8 +33,8 @@
struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val); struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _release)(struct SNAME _map_); void CMC_(PFX, _release)(struct SNAME _map_);
#endif /* CMC_EXT_INIT */ #endif /* CMC_EXT_INIT */
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -60,13 +60,12 @@ struct CMC_DEF_FVAL(SNAME)
struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val); struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _clear)(struct SNAME *_map_);
void CMC_(PFX, _free)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value);
bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value); bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -40,7 +40,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,8 +39,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -167,7 +167,7 @@ void CMC_(PFX, _free)(struct SNAME *_map_)
_map_->alloc->free(_map_); _map_->alloc->free(_map_);
} }
void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -218,7 +218,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value)
_map_->count++; _map_->count++;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, create); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -250,7 +250,7 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, update); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -314,7 +314,7 @@ size_t CMC_(PFX, _update_all)(struct SNAME *_map_, K key, V new_value, V **old_v
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, update); CMC_CALLBACKS_CALL(_map_);
return index; return index;
} }
@@ -401,7 +401,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value)
_map_->count--; _map_->count--;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, delete); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -496,7 +496,7 @@ size_t CMC_(PFX, _remove_all)(struct SNAME *_map_, K key, V **out_values)
_map_->count -= index; _map_->count -= index;
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, delete); CMC_CALLBACKS_CALL(_map_);
return index; return index;
} }
@@ -547,7 +547,7 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -598,7 +598,7 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -625,7 +625,7 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return entry->value; return entry->value;
} }
@@ -652,7 +652,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key)
_map_->flag = CMC_FLAG_OK; _map_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return &(entry->value); return &(entry->value);
} }
@@ -667,7 +667,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key)
bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL; bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL;
CMC_CALLBACKS_CALL(_map_, read); CMC_CALLBACKS_CALL(_map_);
return result; return result;
} }
@@ -813,7 +813,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_map_, resize); CMC_CALLBACKS_CALL(_map_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -60,13 +60,12 @@ struct CMC_DEF_FVAL(SNAME)
struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val); struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key,
struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_map_); void CMC_(PFX, _clear)(struct SNAME *_map_);
void CMC_(PFX, _free)(struct SNAME *_map_); void CMC_(PFX, _free)(struct SNAME *_map_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_map_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value); bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value);
bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value); bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -40,7 +40,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -37,7 +37,7 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -133,7 +133,7 @@ void CMC_(PFX, _free)(struct SNAME *_set_)
_set_->alloc->free(_set_); _set_->alloc->free(_set_);
} }
void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -173,7 +173,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value)
_set_->cardinality++; _set_->cardinality++;
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, create); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -208,7 +208,7 @@ success:
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, create); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -257,7 +257,7 @@ success:
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, update); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -297,7 +297,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value)
_set_->cardinality--; _set_->cardinality--;
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, delete); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -333,7 +333,7 @@ size_t CMC_(PFX, _remove_all)(struct SNAME *_set_, V value)
_set_->cardinality -= removed; _set_->cardinality -= removed;
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, delete); CMC_CALLBACKS_CALL(_set_);
return removed; return removed;
} }
@@ -374,7 +374,7 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value)
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -415,7 +415,7 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value)
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -430,7 +430,7 @@ size_t CMC_(PFX, _multiplicity_of)(struct SNAME *_set_, V value)
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
if (!entry) if (!entry)
return 0; return 0;
@@ -448,7 +448,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value)
bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL; bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
return result; return result;
} }
@@ -594,7 +594,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_set_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_set_, resize); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -42,12 +42,11 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_set_); void CMC_(PFX, _clear)(struct SNAME *_set_);
void CMC_(PFX, _free)(struct SNAME *_set_); void CMC_(PFX, _free)(struct SNAME *_set_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_set_, V value); bool CMC_(PFX, _insert)(struct SNAME *_set_, V value);
bool CMC_(PFX, _insert_many)(struct SNAME *_set_, V value, size_t count); bool CMC_(PFX, _insert_many)(struct SNAME *_set_, V value, size_t count);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ struct SNAME
/* Key function table */ /* Key function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,7 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -131,7 +131,7 @@ void CMC_(PFX, _free)(struct SNAME *_set_)
_set_->alloc->free(_set_); _set_->alloc->free(_set_);
} }
void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -211,7 +211,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value)
_set_->count++; _set_->count++;
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, create); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -243,7 +243,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value)
_set_->count--; _set_->count--;
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, delete); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -284,7 +284,7 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value)
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -325,7 +325,7 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value)
_set_->flag = CMC_FLAG_OK; _set_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -340,7 +340,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value)
bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL; bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL;
CMC_CALLBACKS_CALL(_set_, read); CMC_CALLBACKS_CALL(_set_);
return result; return result;
} }
@@ -474,7 +474,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_set_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_set_, resize); CMC_CALLBACKS_CALL(_set_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -42,12 +42,11 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_set_); void CMC_(PFX, _clear)(struct SNAME *_set_);
void CMC_(PFX, _free)(struct SNAME *_set_); void CMC_(PFX, _free)(struct SNAME *_set_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_set_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_set_, V value); bool CMC_(PFX, _insert)(struct SNAME *_set_, V value);
bool CMC_(PFX, _remove)(struct SNAME *_set_, V value); bool CMC_(PFX, _remove)(struct SNAME *_set_, V value);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -38,7 +38,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+8 -9
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,7 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, enum cmc_heap_order HO, struct CM
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -118,8 +118,7 @@ void CMC_(PFX, _free)(struct SNAME *_heap_)
_heap_->alloc->free(_heap_); _heap_->alloc->free(_heap_);
} }
void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -158,7 +157,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, create); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -184,7 +183,7 @@ bool CMC_(PFX, _remove)(struct SNAME *_heap_)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, delete); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -203,7 +202,7 @@ V CMC_(PFX, _peek)(struct SNAME *_heap_)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, read); CMC_CALLBACKS_CALL(_heap_);
return _heap_->buffer[0]; return _heap_->buffer[0];
} }
@@ -227,7 +226,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value)
} }
} }
CMC_CALLBACKS_CALL(_heap_, read); CMC_CALLBACKS_CALL(_heap_);
return result; return result;
} }
@@ -309,7 +308,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_heap_, size_t capacity)
success: success:
CMC_CALLBACKS_CALL(_heap_, resize); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -42,12 +42,11 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_heap_); void CMC_(PFX, _clear)(struct SNAME *_heap_);
void CMC_(PFX, _free)(struct SNAME *_heap_); void CMC_(PFX, _free)(struct SNAME *_heap_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value); bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value);
bool CMC_(PFX, _remove)(struct SNAME *_heap_); bool CMC_(PFX, _remove)(struct SNAME *_heap_);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -37,7 +37,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -37,8 +37,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL);
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -121,8 +121,7 @@ void CMC_(PFX, _free)(struct SNAME *_heap_)
_heap_->alloc->free(_heap_); _heap_->alloc->free(_heap_);
} }
void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -195,7 +194,7 @@ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value)
/* else no float up required */ /* else no float up required */
} }
CMC_CALLBACKS_CALL(_heap_, create); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -251,7 +250,7 @@ success:
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, delete); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -307,7 +306,7 @@ success:
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, delete); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -347,7 +346,7 @@ bool CMC_(PFX, _update_max)(struct SNAME *_heap_, V value)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, update); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -387,7 +386,7 @@ bool CMC_(PFX, _update_min)(struct SNAME *_heap_, V value)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, update); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -406,7 +405,7 @@ V CMC_(PFX, _max)(struct SNAME *_heap_)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, read); CMC_CALLBACKS_CALL(_heap_);
/* If there is only one element, then the maximum element is the */ /* If there is only one element, then the maximum element is the */
/* same as the one in the MinHeap */ /* same as the one in the MinHeap */
@@ -430,7 +429,7 @@ V CMC_(PFX, _min)(struct SNAME *_heap_)
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, read); CMC_CALLBACKS_CALL(_heap_);
return _heap_->buffer[0][0]; return _heap_->buffer[0][0];
} }
@@ -454,7 +453,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value)
} }
} }
CMC_CALLBACKS_CALL(_heap_, read); CMC_CALLBACKS_CALL(_heap_);
return result; return result;
} }
@@ -549,7 +548,7 @@ success:
_heap_->flag = CMC_FLAG_OK; _heap_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_heap_, resize); CMC_CALLBACKS_CALL(_heap_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -42,13 +42,12 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Functions */ /* Collection Functions */
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_heap_); void CMC_(PFX, _clear)(struct SNAME *_heap_);
void CMC_(PFX, _free)(struct SNAME *_heap_); void CMC_(PFX, _free)(struct SNAME *_heap_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_heap_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value); bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value);
bool CMC_(PFX, _remove_max)(struct SNAME *_heap_); bool CMC_(PFX, _remove_max)(struct SNAME *_heap_);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -38,7 +38,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -35,8 +35,8 @@ struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val)
return CMC_(PFX, _new_custom)(f_val, NULL, NULL); return CMC_(PFX, _new_custom)(f_val, NULL, NULL);
} }
struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -105,8 +105,7 @@ void CMC_(PFX, _free)(struct SNAME *_list_)
_list_->alloc->free(_list_); _list_->alloc->free(_list_);
} }
void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -150,7 +149,7 @@ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value)
_list_->count++; _list_->count++;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -191,7 +190,7 @@ bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index)
_list_->count++; _list_->count++;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -222,7 +221,7 @@ bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value)
_list_->count++; _list_->count++;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -252,7 +251,7 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_list_)
_list_->count--; _list_->count--;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -297,7 +296,7 @@ bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index)
_list_->count--; _list_->count--;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -327,7 +326,7 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_list_)
_list_->count--; _list_->count--;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -346,7 +345,7 @@ V CMC_(PFX, _front)(struct SNAME *_list_)
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return _list_->head->value; return _list_->head->value;
} }
@@ -374,7 +373,7 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index)
if (scan == NULL) if (scan == NULL)
return (V){ 0 }; return (V){ 0 };
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return scan->value; return scan->value;
} }
@@ -402,7 +401,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index)
if (scan == NULL) if (scan == NULL)
return NULL; return NULL;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return &(scan->value); return &(scan->value);
} }
@@ -421,7 +420,7 @@ V CMC_(PFX, _back)(struct SNAME *_list_)
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return _list_->tail->value; return _list_->tail->value;
} }
@@ -449,7 +448,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value)
scan = scan->next; scan = scan->next;
} }
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return result; return result;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -42,13 +42,12 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Functions */ /* Collection Functions */
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val); 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_ALLOC_NODE_NAME *alloc, struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_list_); void CMC_(PFX, _clear)(struct SNAME *_list_);
void CMC_(PFX, _free)(struct SNAME *_list_); void CMC_(PFX, _free)(struct SNAME *_list_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value); 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_at)(struct SNAME *_list_, V value, size_t index);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -41,7 +41,7 @@ struct SNAME
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+43 -29
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -43,11 +43,11 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
} }
#ifdef CMC_SAC #ifdef CMC_SAC
struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
#else #else
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
#endif #endif
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
@@ -61,9 +61,6 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME)
return NULL; return NULL;
#endif #endif
if (!f_val)
return NULL;
if (!alloc) if (!alloc)
alloc = &cmc_alloc_node_default; alloc = &cmc_alloc_node_default;
@@ -104,7 +101,7 @@ void CMC_(PFX, _clear)(struct SNAME *_list_)
CMC_DEV_FCALL; CMC_DEV_FCALL;
#endif #endif
if (_list_->f_val->free) if (_list_->f_val && _list_->f_val->free)
{ {
for (size_t i = 0; i < _list_->count; i++) for (size_t i = 0; i < _list_->count; i++)
_list_->f_val->free(_list_->buffer[i]); _list_->f_val->free(_list_->buffer[i]);
@@ -126,7 +123,7 @@ void CMC_(PFX, _free)(struct SNAME *_list_)
CMC_DEV_FCALL; CMC_DEV_FCALL;
#endif #endif
if (_list_->f_val->free) if (_list_->f_val && _list_->f_val->free)
{ {
for (size_t i = 0; i < _list_->count; i++) for (size_t i = 0; i < _list_->count; i++)
_list_->f_val->free(_list_->buffer[i]); _list_->f_val->free(_list_->buffer[i]);
@@ -138,8 +135,7 @@ void CMC_(PFX, _free)(struct SNAME *_list_)
_list_->alloc->free(_list_); _list_->alloc->free(_list_);
} }
void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -188,7 +184,7 @@ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value)
_list_->count++; _list_->count++;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -222,7 +218,7 @@ bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index)
_list_->count++; _list_->count++;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -247,7 +243,7 @@ bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value)
_list_->buffer[_list_->count++] = value; _list_->buffer[_list_->count++] = value;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -269,7 +265,7 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_list_)
_list_->buffer[--_list_->count] = (V){ 0 }; _list_->buffer[--_list_->count] = (V){ 0 };
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -297,7 +293,7 @@ bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index)
_list_->buffer[--_list_->count] = (V){ 0 }; _list_->buffer[--_list_->count] = (V){ 0 };
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -309,12 +305,16 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_list_)
#endif #endif
if (CMC_(PFX, _empty)(_list_)) if (CMC_(PFX, _empty)(_list_))
{
_list_->flag = CMC_FLAG_EMPTY;
CMC_CALLBACKS_CALL(_list_);
return false; return false;
}
_list_->buffer[--_list_->count] = (V){ 0 }; _list_->buffer[--_list_->count] = (V){ 0 };
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -333,7 +333,7 @@ V CMC_(PFX, _front)(struct SNAME *_list_)
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return _list_->buffer[0]; return _list_->buffer[0];
} }
@@ -347,18 +347,20 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index)
if (CMC_(PFX, _empty)(_list_)) if (CMC_(PFX, _empty)(_list_))
{ {
_list_->flag = CMC_FLAG_EMPTY; _list_->flag = CMC_FLAG_EMPTY;
CMC_CALLBACKS_CALL(_list_);
return (V){ 0 }; return (V){ 0 };
} }
if (index >= _list_->count) if (index >= _list_->count)
{ {
_list_->flag = CMC_FLAG_RANGE; _list_->flag = CMC_FLAG_RANGE;
CMC_CALLBACKS_CALL(_list_);
return (V){ 0 }; return (V){ 0 };
} }
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return _list_->buffer[index]; return _list_->buffer[index];
} }
@@ -383,7 +385,7 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index)
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return &(_list_->buffer[index]); return &(_list_->buffer[index]);
} }
@@ -402,7 +404,7 @@ V CMC_(PFX, _back)(struct SNAME *_list_)
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return _list_->buffer[_list_->count - 1]; return _list_->buffer[_list_->count - 1];
} }
@@ -413,6 +415,12 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start)
CMC_DEV_FCALL; CMC_DEV_FCALL;
#endif #endif
if (_list_->f_val == NULL || _list_->f_val->cmp == NULL)
{
_list_->flag = CMC_FLAG_FTABLE;
return 0;
}
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
size_t result = _list_->count; size_t result = _list_->count;
@@ -421,7 +429,7 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start)
{ {
for (size_t i = 0; i < _list_->count; i++) for (size_t i = 0; i < _list_->count; i++)
{ {
if (_list_->f_val->cmp(_list_->buffer[i], value) == 0) if (0 == _list_->f_val->cmp(_list_->buffer[i], value))
{ {
result = i; result = i;
break; break;
@@ -432,7 +440,7 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start)
{ {
for (size_t i = _list_->count; i > 0; i--) for (size_t i = _list_->count; i > 0; i--)
{ {
if (_list_->f_val->cmp(_list_->buffer[i - 1], value) == 0) if (0 == _list_->f_val->cmp(_list_->buffer[i - 1], value))
{ {
result = i - 1; result = i - 1;
break; break;
@@ -440,7 +448,7 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start)
} }
} }
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return result; return result;
} }
@@ -451,20 +459,26 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value)
CMC_DEV_FCALL; CMC_DEV_FCALL;
#endif #endif
if (_list_->f_val == NULL || _list_->f_val->cmp == NULL)
{
_list_->flag = CMC_FLAG_FTABLE;
return false;
}
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
bool result = false; bool result = false;
for (size_t i = 0; i < _list_->count; i++) for (size_t i = 0; i < _list_->count; i++)
{ {
if (_list_->f_val->cmp(_list_->buffer[i], value) == 0) if (0 == _list_->f_val->cmp(_list_->buffer[i], value))
{ {
result = true; result = true;
break; break;
} }
} }
CMC_CALLBACKS_CALL(_list_, read); CMC_CALLBACKS_CALL(_list_);
return result; return result;
} }
@@ -567,7 +581,7 @@ bool CMC_(PFX, _resize)(struct SNAME *_list_, size_t capacity)
_list_->buffer = new_buffer; _list_->buffer = new_buffer;
_list_->capacity = capacity; _list_->capacity = capacity;
CMC_CALLBACKS_CALL(_list_, resize); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -593,7 +607,7 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_)
CMC_CALLBACKS_ASSIGN(result, _list_->callbacks); CMC_CALLBACKS_ASSIGN(result, _list_->callbacks);
if (_list_->f_val->cpy) if (_list_->f_val && _list_->f_val->cpy)
{ {
for (size_t i = 0; i < _list_->count; i++) for (size_t i = 0; i < _list_->count; i++)
result->buffer[i] = _list_->f_val->cpy(_list_->buffer[i]); result->buffer[i] = _list_->f_val->cpy(_list_->buffer[i]);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -48,11 +48,11 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
} }
#ifdef CMC_SAC #ifdef CMC_SAC
struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
#else #else
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
#endif #endif
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
@@ -397,7 +397,7 @@ bool CMC_(PFX, _seq_push_front)(struct SNAME *_list_, V *values, size_t size)
_list_->count += size; _list_->count += size;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -443,7 +443,7 @@ bool CMC_(PFX, _seq_push_at)(struct SNAME *_list_, V *values, size_t size, size_
_list_->count += size; _list_->count += size;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -476,7 +476,7 @@ bool CMC_(PFX, _seq_push_back)(struct SNAME *_list_, V *values, size_t size)
_list_->count += size; _list_->count += size;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, create); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -508,7 +508,7 @@ bool CMC_(PFX, _seq_pop_at)(struct SNAME *_list_, size_t from, size_t to)
_list_->count -= to - from + 1; _list_->count -= to - from + 1;
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return true; return true;
} }
@@ -556,7 +556,7 @@ struct SNAME *CMC_(PFX, _seq_sublist)(struct SNAME *_list_, size_t from, size_t
_list_->flag = CMC_FLAG_OK; _list_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_list_, delete); CMC_CALLBACKS_CALL(_list_);
return result; return result;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -32,12 +32,12 @@
#ifdef CMC_SAC #ifdef CMC_SAC
struct SNAME CMC_(PFX, _init)(struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME CMC_(PFX, _init)(struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct SNAME CMC_(PFX, _init_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
#else #else
struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
#endif #endif
void CMC_(PFX, _release)(struct SNAME _list_); void CMC_(PFX, _release)(struct SNAME _list_);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -42,18 +42,17 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
#ifdef CMC_SAC #ifdef CMC_SAC
struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val); 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_ALLOC_NODE_NAME *alloc, struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
#else #else
struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
#endif #endif
void CMC_(PFX, _clear)(struct SNAME *_list_); void CMC_(PFX, _clear)(struct SNAME *_list_);
void CMC_(PFX, _free)(struct SNAME *_list_); void CMC_(PFX, _free)(struct SNAME *_list_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_list_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value); 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_at)(struct SNAME *_list_, V value, size_t index);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+9 -10
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -34,8 +34,8 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL);
} }
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -121,8 +121,7 @@ void CMC_(PFX, _free)(struct SNAME *_queue_)
_queue_->alloc->free(_queue_); _queue_->alloc->free(_queue_);
} }
void CMC_(PFX, _customize)(struct SNAME *_queue_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_queue_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks)
struct CMC_CALLBACKS_NAME *callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -158,7 +157,7 @@ bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value)
_queue_->count++; _queue_->count++;
_queue_->flag = CMC_FLAG_OK; _queue_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_queue_, create); CMC_CALLBACKS_CALL(_queue_);
return true; return true;
} }
@@ -181,7 +180,7 @@ bool CMC_(PFX, _dequeue)(struct SNAME *_queue_)
_queue_->count--; _queue_->count--;
_queue_->flag = CMC_FLAG_OK; _queue_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_queue_, delete); CMC_CALLBACKS_CALL(_queue_);
return true; return true;
} }
@@ -200,7 +199,7 @@ V CMC_(PFX, _peek)(struct SNAME *_queue_)
_queue_->flag = CMC_FLAG_OK; _queue_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_queue_, read); CMC_CALLBACKS_CALL(_queue_);
return _queue_->buffer[_queue_->front]; return _queue_->buffer[_queue_->front];
} }
@@ -226,7 +225,7 @@ bool CMC_(PFX, _contains)(struct SNAME *_queue_, V value)
i = (i + 1) % _queue_->capacity; i = (i + 1) % _queue_->capacity;
} }
CMC_CALLBACKS_CALL(_queue_, read); CMC_CALLBACKS_CALL(_queue_);
return result; return result;
} }
@@ -317,7 +316,7 @@ success:
_queue_->flag = CMC_FLAG_OK; _queue_->flag = CMC_FLAG_OK;
CMC_CALLBACKS_CALL(_queue_, resize); CMC_CALLBACKS_CALL(_queue_);
return true; return true;
} }
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,8 +39,8 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_va
return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL);
} }
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) CMC_CALLBACK_TYPE callbacks)
{ {
#ifdef CMC_DEV #ifdef CMC_DEV
CMC_DEV_FCALL; CMC_DEV_FCALL;
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -31,8 +31,8 @@
#ifdef CMC_EXT_INIT #ifdef CMC_EXT_INIT
struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _release)(struct SNAME _queue_); void CMC_(PFX, _release)(struct SNAME _queue_);
#endif /* CMC_EXT_INIT */ #endif /* CMC_EXT_INIT */
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -41,13 +41,12 @@ struct CMC_DEF_FVAL(SNAME)
/* Collection Allocation and Deallocation */ /* Collection Allocation and Deallocation */
struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val); struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val);
struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, CMC_ALLOC_TYPE alloc,
struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks); CMC_CALLBACK_TYPE callbacks);
void CMC_(PFX, _clear)(struct SNAME *_queue_); void CMC_(PFX, _clear)(struct SNAME *_queue_);
void CMC_(PFX, _free)(struct SNAME *_queue_); void CMC_(PFX, _free)(struct SNAME *_queue_);
/* Customization of Allocation and Callbacks */ /* Customization of Allocation and Callbacks */
void CMC_(PFX, _customize)(struct SNAME *_queue_, struct CMC_ALLOC_NODE_NAME *alloc, void CMC_(PFX, _customize)(struct SNAME *_queue_, CMC_ALLOC_TYPE alloc, CMC_CALLBACK_TYPE callbacks);
struct CMC_CALLBACKS_NAME *callbacks);
/* Collection Input and Output */ /* Collection Input and Output */
bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value); bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value);
bool CMC_(PFX, _dequeue)(struct SNAME *_queue_); bool CMC_(PFX, _dequeue)(struct SNAME *_queue_);
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2019 Leonardo Vencovsky * Copyright (c) 2019 Leonardo Vencovsky
* *
* This file is part of the C Macro Collections Libray. * This file is part of the C Macro Collections Library.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ struct SNAME
/* Value function table */ /* Value function table */
struct CMC_DEF_FVAL(SNAME) * f_val; struct CMC_DEF_FVAL(SNAME) * f_val;
/* Custom allocation functions */ /* Custom allocation functions */
struct CMC_ALLOC_NODE_NAME *alloc; CMC_ALLOC_TYPE alloc;
/* Custom callback functions */ /* Custom callback functions */
CMC_CALLBACKS_DECL; CMC_CALLBACKS_DECL;
}; };
Loaded 100 of 156 files, more files were not shown because too many files have changed in this diff. Show more