Example #1
0
File: listins.c Project: ZOO-OO/IU9
int main() {
	long int i, n;
	Elem *list = list_create_elem(), *y, *p;
	scanf("%ld", &n);
	for (i = 0; i < n; i++) {
		y = list_create_elem();
		scanf("%d", &(y->v));
		list_add_after(list, y);
	}
	list_ins_sort(list);
	for (y = list->next; y != list;) {
		printf("%d ", y->v);
		p = y->next;
		free(y);
		y = p;
	}
	free(list);
	return 0;
}
Example #2
0
void				add_gol_elem(t_list *list, int32_t x, int32_t y)
{
	t_gol			*const gol = bitset_gol_create(x, y, 2);
	t_elem			*const elem = list_create_elem(0);

	if (!gol || !elem)
		exit(0);
	elem->data = gol;
	if (!list_push_back(list, elem))
		exit(0);
}
Example #3
0
int main() {
	list* list = list_new(sizeof(int), 4);
	
	int* val = list_create_elem(list);
	*val = 50;
	int* val2 = list_create_elem(list);
	*val2 = 100;
	list_add(list, val, sizeof(int));
	list_add(list, val2, sizeof(int));

	int *end = list_end(list);
	for (int i = 0; i < list->count; i++) {
		int *val = list->buf[i];
		printf("%d\n", *val);
	}
	

	list_free(list);
	
	return 0;
}