You can not.
However, you can create something similar using data structures.
struct vector {
void* data;
size_t size;
size_t capacity
};
, , int* . realloc, . "" - , -
. ( , 1 -
).
, :
struct linked_list_node {
void* data;
struct linked_list_node* next;
};
, int, ( , ).
. , :
struct linked_list {
struct linked_list_node* start;
struct linked_list_node* end;
};
.
-
args: {
struct linked_list* list = malloc(sizeof(struct linked_list));
struct linked_list_node* node = malloc(sizeof(struct linked_list_node));
list->start = node;
list->end = node;
$$ = list;
}
|
args arg {
struct linked_list_node* node = malloc(sizeof(struct linked_list_node));
int val = $2;
node->data = &val;
struct linked_list* list = $1;
list->end->next = node;
list->end = node;
$$ = list;
}
;
( )
, . . , , .
O(1) , ( , ). , , O(n). , , O(n) . O(1).