void queue_pop(Queue* queue)
{
- //remove first vector element and shift its internal array
- safe_free(queue->array->datas[0]);
- queue->array->datas++;
- //NOTE: we remove first element, so capacity decrease too
- queue->array->size--;
- queue->array->capacity--;
+ vector_pop_first(queue->array);
+
}
void queue_clear(Queue* queue)
_vector_realloc(vector, vector->capacity >> 1);
}
+void vector_pop_first(Vector* vector)
+{
+ safe_free(vector->datas[0]);
+ vector->datas++;
+ vector->size--;
+ if (vector_size(vector) <= (vector->capacity >> 1))
+ _vector_realloc(vector, vector->capacity >> 1);
+}
+
void* _vector_get(Vector* vector, UInt index)
{
return vector->datas[index];
int main(int argc, char** argv)
{
- //file ./t.Stack.c :
- t_stack_clear();
- t_stack_size();
- t_stack_push_pop_basic();
- t_stack_push_pop_evolved();
- t_stack_copy();
+ //file ./t.Vector.c :
+ void t_vector_clear();
+ void t_vector_size();
+ void t_vector_push_pop_basic();
+ void t_vector_push_pop_evolved();
+ void t_vector_copy();
- //file ./t.Heap.c :
- t_heap_clear();
- t_heap_size();
- t_heap_push_pop_basic();
- t_heap_push_pop_evolved();
- t_heap_copy();
+ //file ./t.BufferTop.c :
+ void t_buffertop_clear();
+ void t_buffertop_size();
+ void t_buffertop_push_pop_basic();
+ void t_buffertop_push_pop_evolved();
+ void t_buffertop_copy();
//file ./t.Tree.c :
- t_tree_clear();
- t_tree_size();
- t_tree_add_remove();
- t_tree_iterate();
- t_tree_copy();
+ void t_tree_clear();
+ void t_tree_size();
+ void t_tree_add_remove();
+ void t_tree_iterate();
+ void t_tree_copy();
- //file ./t.PriorityQueue.c :
- t_priorityqueue_clear();
- t_priorityqueue_size();
- t_priorityqueue_push_pop_basic();
- t_priorityqueue_push_pop_evolved();
- t_priorityqueue_copy();
+ //file ./t.Heap.c :
+ void t_heap_clear();
+ void t_heap_size();
+ void t_heap_push_pop_basic();
+ void t_heap_push_pop_evolved();
+ void t_heap_copy();
//file ./t.List.c :
- t_list_clear();
- t_list_size();
- t_list_push_pop_basic();
- t_list_push_pop_evolved();
- t_list_copy();
-
- //file ./t.Vector.c :
- t_vector_clear();
- t_vector_size();
- t_vector_push_pop_basic();
- t_vector_push_pop_evolved();
- t_vector_copy();
+ void t_list_clear();
+ void t_list_size();
+ void t_list_push_pop_basic();
+ void t_list_push_pop_evolved();
+ void t_list_copy();
//file ./t.Queue.c :
- t_queue_clear();
- t_queue_size();
- t_queue_push_pop_basic();
- t_queue_push_pop_evolved();
- t_queue_copy();
+ void t_queue_clear();
+ void t_queue_size();
+ void t_queue_push_pop_basic();
+ void t_queue_push_pop_evolved();
+ void t_queue_copy();
- //file ./t.BufferTop.c :
- t_buffertop_clear();
- t_buffertop_size();
- t_buffertop_push_pop_basic();
- t_buffertop_push_pop_evolved();
- t_buffertop_copy();
+ //file ./t.Stack.c :
+ void t_stack_clear();
+ void t_stack_size();
+ void t_stack_push_pop_basic();
+ void t_stack_push_pop_evolved();
+ void t_stack_copy();
+
+ //file ./t.PriorityQueue.c :
+ void t_priorityqueue_clear();
+ void t_priorityqueue_size();
+ void t_priorityqueue_push_pop_basic();
+ void t_priorityqueue_push_pop_evolved();
+ void t_priorityqueue_copy();
return 0;
}
#add functions
for file in `find . -type f -name \*.c ! -name main.c`; do
printf "\t//file $file :\n" >> main.c
- functions=`grep "//FTEST" $file | sed 's/void \(.\+\) \/\/FTEST/\t\1;/g'`
+ functions=`grep '^ *void t_' $file | sed 's/^ *\(void [^(]*\).*/\t\1();/g'`
printf "$functions" >> main.c
- printf "\n\n" >> main.c
+ printf '\n\n' >> main.c
done
#finalize main.c
-printf "\treturn 0;\n" >> main.c
+printf '\treturn 0;\n' >> main.c
printf '}\n' >> main.c