Documentation
Syntax quick tour
vector
#include "oml_debug.h"
#include "oml_vector.h"
typedef ... myType, *pMyType;
oml_define_vector(pMyType);
...
myType myObj1;
pMyType pObj;
oml_vector(pMyType) v; // template-like syntax
oml_assert_ok(oml_vector_init(&v, 16)); // Provide maximum size
oml_assert_ok(oml_vector_push(&v, pObj));
oml_assert_ok(oml_vector_push(&v, pObj));
oml_vector_iterator(pMyType) it;
for (oml_vector_begin(&v, &it); oml_vector_has_next(&v, &it); oml_vector_next(&v, &it)) {
oml_assert_ok(oml_vector_get_next(&v, &it, &pObj));
// Use pObj
}
for (oml_vector_end(&v, &it); oml_vector_has_prev(&v, &it); oml_vector_prev(&v, &it)) {
oml_assert_ok(oml_vector_get_prev(&v, &it, &pObj));
// Use pObj
}
vstack
#include "oml_debug.h"
#include "oml_vstack.h"
typedef ... myType, *pMyType;
oml_define_vstack(pMyType);
...
myType myObj1;
pMyType pObj;
oml_vstack(pMyType) v; // template-like syntax
oml_assert_ok(oml_vstack_init(&v, 16)); // Provide maximum size
oml_assert_ok(oml_vstack_push(&v, pObj));
oml_assert_ok(oml_vstack_push(&v, pObj));
oml_assert_ok(oml_vstack_pop(&v, &pObj));
// Use pObj
oml_assert_ok(oml_vstack_pop(&v, &pObj));
// Use pObj
oml_vstack_iterator(pMyType) it;
for (oml_vstack_begin(&v, &it); oml_vstack_has_next(&v, &it); oml_vstack_next(&v, &it)) {
oml_assert_ok(oml_vstack_get_next(&v, &it, &pObj));
// Use pObj
}
heap
#include "oml_heap.h"
typedef ... myType, *pMyType;
oml_define_heap(int, pMyType);
#define HEAP_BITS 3
#define HEAP_SIZE (1 << HEAP_BITS)
...
int k;
myType myObj1;
pMyType pObj;
oml_heap(int, pMyType) h; // template-like syntax
rv = oml_heap_init(&h, HEAP_BITS);
rv = oml_heap_add(&h, 4, &myObj1);
rv = oml_heap_get_min(&h, &k, &pObj);
|