Collection of Reliable Data Container Structures for Standard C
- Define your type
typedef struct {
char name[20];
int param_a;
unsigned int param_b;
} NameAndValue;- Allocate space for the container
#define STACKSIZE 16
NameAndValue name_and_values[STACKSIZE];- Initialize the container
DcsStack nv_stack = dcsstack_init(sizeof(NameAndValue), STACKSIZE, name_and_values);- Use the container
NameAndValue nv0 = {"Foo", -123, 4};
dcsstack_push(&nv_stack, &nv0);
int nv_size = dcsstack_size(&nv_stack);
// etc.Either clone the git source or download and extract the zip. Cloning git source is preferred.
First, you need to run aclocal.
Next, run autoconf.
Finally, run automake --add-missing.
aclocal
autoconf
automake --add-missingThe INSTALL file already describes how to run the configure script.
Installation prefix, compiler, target platform, etc. can be overridden at this step.
./configure
make
make installThe make process compiles -along with other source files- the example files. The example binaries are placed in the examples directory. Check them out, e.g.,
examples/dcshashset_xmpl1_demo| Structure | Description | Implementation | Documentation | Tests | Examples |
|---|---|---|---|---|---|
| DcsFIFO | Circular buffer based FIFO | missing | missing | missing | missing |
| DcsHashSet | Capacity constrained hashset | READY | READY | missing | 2 |
| DcsHS | Size optimized hashset | missing | missing | missing | missing |
| DcsHoF | Hall of Fame -- stores Top N elements | READY | READY | missing | 1 |
| DcsLinSet | Array based, ordered set | READY | in progress | missing | missing |
| DcsHashMultiMap | Multiple values with the same key | missing | missing | missing | missing |
| DcsStack | Simple, size constrained stack | READY | missing | missing | 1 |
-
No dynamic memory allocation
Memory area has to be allocated by the user. Initializer functions take a reference to the pre-allocated memory area as parameter.
-
Access to container elements via byte pointers
Standard C language does not support templates. There are multiple ways to overcome this gap. BilisDcs has chosen to employ the generic type: byte pointer (ElementPtr). Also, the size of the stored type (itemsize) always must be given at initialization of the container structure.
-
Iterators and iterator functions
Functions
~_begin()and~_end()are defined for each container. Since the standard C language does not support operator overload, operators on iterators are also defined as functions:~_iterator_equals()~_next_iterator()~_deref_iterator()