summaryrefslogtreecommitdiffhomepage
path: root/docs/cstack_api.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/cstack_api.md')
-rw-r--r--docs/cstack_api.md25
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/cstack_api.md b/docs/cstack_api.md
index 3d9ecd4f..68f22b57 100644
--- a/docs/cstack_api.md
+++ b/docs/cstack_api.md
@@ -1,21 +1,23 @@
# STC [cstack](../include/stc/cstack.h): Stack
![Stack](pics/stack.jpg)
-The **cstack** is a container adapter that gives the programmer the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure. The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The stack pushes and pops the element from the back of the underlying container, known as the top of the stack.
+The **cstack** is a container that gives the programmer the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure. The stack pushes and pops the element from the back of the underlying container, known as the top of the stack.
-See the c++ class [std::stack](https://en.cppreference.com/w/cpp/container/stack) for a functional description.
+See the c++ class [std::stack](https://en.cppreference.com/w/cpp/container/stack) for a functional description.
## Header file and declaration
```c
-#include <stc/cstack.h> /* includes default underlying implementation header cvec.h */
-
-using_cstack(X, ctype)
+#define i_tag // defaults to i_val name
+#define i_val // value: REQUIRED
+#define i_cmp // three-way compare two i_valraw* : REQUIRED IF i_valraw is a non-integral type
+#define i_valraw // convertion "raw" type - defaults to i_val
+#define i_valfrom // convertion func i_valraw => i_val - defaults to plain copy
+#define i_valto // convertion func i_val* => i_valraw - defaults to plain copy
+#define i_valdel // destroy value func - defaults to empty destruct
+#include <stc/cstack.h>
```
-The macro `using_cstack()` must be instantiated in the global scope. **cstack** uses normally
-a **cvec_X** or **cdeq_X** type as underlying implementation, given as `ctype`. `X` is a type tag name and will
-affect the names of all cstack types and methods. E.g. declaring `using_cstack(i, cvec_i);`,
-`X` should be replaced by `i` in all of the following documentation.
+`X` should be replaced by the value of i_tag in all of the following documentation.
## Methods
@@ -54,12 +56,11 @@ cstack_X_value_t cstack_X_value_clone(cstack_X_value_t val);
## Example
```c
+#define i_tag i
+#define i_val int
#include <stc/cstack.h>
#include <stdio.h>
-using_cvec(i, int);
-using_cstack(i, cvec_i);
-
int main() {
cstack_i S = cstack_i_init();