Have you ever experienced the full power of Python list with tons of useful methods and then switching back to a C project with poor but incredibly
fast arrays?
This lightweight library provides a simple way to use Python-like list in a C environment without too much overhead.
This library is much inspired by both Python list and Java List interface, to provide something similar in C without impacting performance.
It uses a lot of C Preprocessor commands to provide support for any desired
type in the same project (but not inside the same vector).
Be careful! This library comes with only a few security measures, and should not be used in security-dependant apps. The library is still in alpha phase, any comment or bug/issue report would be useful!
The full documentation is generated by Doxygen! Just read it there !
Link to the documentation: online documentation
You can also download the offline documentation there: PDF documentation
DON'T FORGET TO LINK THE MATH LIBRARY
What you should put in your project is the two .h files of lib:
cvector_interface.h and cvector_core.h
Then, for each required type (denoted $TYPE here, which MUST be a
valid C identifier), create the following files
$TYPE_vect.h
#ifndef DEF_$TYPE_VECT
#define DEF_$TYPE_VECT
// If your $TYPE is not a primitive one, for example "typedef char * str;"
typedef $SOMETHING $TYPE;
#define CVECTOR_T $TYPE
#define CVECTOR_DEFAULT_VALUE $YOUR_TYPE_DEFAULT_VALUE
// Put your options ("#define CVECTOR_ERROR_FUNC"...) here
#include "cvector_interface.h"
#endif // DEF_$TYPE_VECT$TYPE_vect.c
#include "$TYPE_vect.h"
#include "cvector_core.h"Then, you can use these .h and .c files like the other ones.
int_vect.h
#ifndef DEF_INT_VECT
#define DEF_INT_VECT
#include "cvector_interface.h"
#endif // DEF_INT_VECTint_vect.c
#include "int_vect.h"
#include "cvector_core.h"str_vect.h
#ifndef DEF_STR_VECT
#define DEF_STR_VECT
typedef char * str;
#define CVECTOR_T str
#define CVECTOR_DEFAULT_VALUE NULL
#include "cvector_interface.h"
#endif // DEF_STR_VECTstr_vect.c
#include "str_vect.h"
#include "cvector_core.h"N.B. These examples are present in the includes directory.
Copyright (C) 2018 Thomas BAGREL
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.0.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Thomas BAGREL, student in Lycée H. Poincaré, Nancy, France
Contact me at: tomsb07 at gmail dot com!