made work: get/set at index in list
This commit is contained in:
@@ -1,41 +1,30 @@
|
||||
#include <odweta/list.h>
|
||||
#include <odweta/vector.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
list_t* another_list = listInit();
|
||||
|
||||
listPush(another_list, CHAR, &(char){'x'});
|
||||
listPush(another_list, INT, &(int){123});
|
||||
listPush(another_list, FLOAT, &(float){3.14});
|
||||
printf("do not put the list into itself, it does weird stuff\n");
|
||||
// BIG NONO -> listPush(another_list, LIST, another_list);
|
||||
|
||||
listRemoveAt(another_list, 1);
|
||||
|
||||
list_t* l = listInit();
|
||||
|
||||
listPush(l, INT, &(int){5+2});
|
||||
listPush(l, INT, &(int){5*2});
|
||||
listPush(l, FLOAT, &(float){5/2});
|
||||
listPush(l, INT, &(int){5});
|
||||
listPush(l, INT, &(int){2});
|
||||
listPush(l, INT, &(int){1});
|
||||
|
||||
listPush(another_list, LIST, l);
|
||||
listSetAt(l, 1, FLOAT, &(float){3.14});
|
||||
|
||||
listPrint(another_list);
|
||||
printf("value at index 2 in list l:\n");
|
||||
int val = *((int*)listGetAt(l, 2));
|
||||
printf("%d\n", val);
|
||||
|
||||
listCleanup(another_list);
|
||||
list_t* m = listInit();
|
||||
|
||||
// vector_t* v = vectorInit(INT);
|
||||
//
|
||||
// vectorPush(v, &(int){123});
|
||||
// vectorPush(v, &(int){456});
|
||||
// vectorPush(v, &(int){789});
|
||||
//
|
||||
// vectorRemoveAt(v, 1);
|
||||
//
|
||||
// vectorPrint(v);
|
||||
//
|
||||
// vectorCleanup(v);
|
||||
listPush(m, CHAR, &(char){'a'});
|
||||
listPush(m, CHAR, &(char){'b'});
|
||||
listPush(m, CHAR, &(char){'c'});
|
||||
|
||||
listSetAt(l, 2, LIST, m);
|
||||
|
||||
listPrint(l);
|
||||
|
||||
listCleanup(l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user