REFACTOR: Completely redid push_back and create
This commit is contained in:
+15
-83
@@ -14,97 +14,29 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "char.h"
|
||||
#include "utils.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
Vec8_t vec = create(nullptr);
|
||||
Vec8_t other = create(nullptr);
|
||||
|
||||
char arr[] = { 'a' };
|
||||
// Vec8_t v1 = create(arr, find_len(arr));
|
||||
// Vec8_t v1 = create((char[]) { 'a', 'b', 'c', 'd' }, 4);
|
||||
Vec8_t v1 = create(nullptr, 0);
|
||||
// v1 = reserve(&v1, 10);
|
||||
// v1 = pop_back(&v1);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
vec = add_back(&vec, 'a');
|
||||
v1 = push_back(&v1, 'a');
|
||||
}
|
||||
print_vec(&vec);
|
||||
printf("\n");
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
other = add_back(&other, 'b');
|
||||
}
|
||||
print_vec(&other);
|
||||
|
||||
printf("Vec: ");
|
||||
// for (int i = 0; i < vec.size; i++)
|
||||
// {
|
||||
// printf("%i ", at(&vec, i));
|
||||
// }
|
||||
print_vec(&vec);
|
||||
printf("\n");
|
||||
|
||||
// vec = resize(&vec, 12, 'a');
|
||||
|
||||
printf("Vec: ");
|
||||
vec = assign(&vec, &other, begin(&other) + 2, end(&other) + 1);
|
||||
vec = shrink_to_fit(&vec);
|
||||
print_vec(&vec);
|
||||
// for (int i = 0; i < vec.size; i++)
|
||||
// {
|
||||
// printf("%i ", at(&vec, i));
|
||||
// }
|
||||
// printf("\n");
|
||||
// print_vec(&vec);
|
||||
// pop_back(&vec);
|
||||
// printf("Other: ");
|
||||
// print_vec(&other);
|
||||
// printf("\n");
|
||||
//
|
||||
// printf("Vec: ");
|
||||
// print_vec(&vec);
|
||||
// printf("\n");
|
||||
// pop_back(&vec);
|
||||
// printf("Other: ");
|
||||
// print_vec(&other);
|
||||
// printf("\n");
|
||||
//
|
||||
// int error = swap(&vec, &other);
|
||||
// if (error)
|
||||
// {
|
||||
// printf("Vec: ");
|
||||
// print_vec(&vec);
|
||||
// printf("\n");
|
||||
// printf("Other: ");
|
||||
// print_vec(&other);
|
||||
// }
|
||||
|
||||
// Vec8_t vec = create(false);
|
||||
|
||||
// vec = add_back(&vec, '3');
|
||||
// vec = add_back(&vec, '4');
|
||||
// vec = add_back(&vec, '5');
|
||||
// vec = add_back(&vec, '6');
|
||||
// vec = add_back(&vec, '8');
|
||||
// vec = add_back(&vec, '6');
|
||||
|
||||
// for (int i = 0; i < vec.capacity; i++)
|
||||
// {
|
||||
// printf("%i\n", vec.arr[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
// printf("\n");
|
||||
//
|
||||
// vec = shrink_to_fit(&vec);
|
||||
// for (int i = 0; i < vec.capacity; i++)
|
||||
// {
|
||||
// printf("%i\n", vec.arr[i]);
|
||||
// }
|
||||
// vec = *erase(&vec, begin(&vec) + 2, begin(&vec) + 4);
|
||||
// print_vec(&vec);
|
||||
// printf("%p", data(&vec));
|
||||
|
||||
delete(&vec);
|
||||
delete(&other);
|
||||
print_vec(&v1);
|
||||
printf("SIZE: %zu\n", v1.size);
|
||||
v1 = push_back(&v1, 'a');
|
||||
print_vec(&v1);
|
||||
printf("SIZE: %zu\n", v1.size);
|
||||
delete(&v1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user