#include <stdio.h>
#include "stack.h"
int main(int argc, char **argv)
{
stack_t *stack = NULL;
node_t *node = NULL;
int d1 = 4;
double d2 = 2.6;
stack_init(&stack);
stack_push(stack, &d1);
stack_push(stack, &d2);
printf("Items in stack: %ld\n", stack_size(stack));
node = stack_pop(stack);
printf("Node value: %f\n", *((double*)node->data));
printf("Items in stack after pop: %ld\n", stack_size(stack));
node_destroy(node);
printf("Stack top value: %d\n", *((int*)stack->top->data));
stack_destroy(&stack);
return 0;
}
#include <stdio.h>
#include "vector.h"
int main(int argc, char **argv)
{
vector_t *vec = NULL;
int *vec_item = NULL;
int i;
vector_init(&vec);
printf("Vector size: %ld\n", vector_size(vec));
printf("Vector capacity: %ld\n", vector_capacity(vec));
for (i = 0; i < 10; i++)
{
vector_add(vec, &i);
}
printf("Vector size: %ld\n", vector_size(vec));
printf("Vector capacity: %ld\n", vector_capacity(vec));
for (i = 0; i < 10; i++)
printf("item %d: %d\n", i, *((int*)vec->items[i]));
vector_trim(vec);
printf("Vector size: %ld\n", vector_size(vec));
printf("Vector capacity: %ld\n", vector_capacity(vec));
vec_item = vector_pop(vec);
printf("Popped item: %d\n", *vec_item);
free(vec_item);
vector_destroy(&vec);
if (vec == NULL)
printf("Vector is NULL\n");
return 0;
}