Fixed up where there was no error checking of position when inserting into a position into the list. Also made it so that listCreate returns a pointer to a list instead of a list so that we can move the definition of List into the implementation file instead of the header.
60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
#include "types/linked_list.h"
|
|
#include <defines.h>
|
|
#include <logger/logger.h>
|
|
#include <memory/zone.h>
|
|
|
|
int main() {
|
|
QINFO("Size of i16: %" PRId16, sizeof(i16));
|
|
QINFO("Size of u16: %" PRIu16, sizeof(u16));
|
|
QINFO("Size of i32: %" PRId32, sizeof(i32));
|
|
QINFO("Size of u32: %" PRIu32, sizeof(u32));
|
|
QINFO("Size of i64: %" PRId64, sizeof(i64));
|
|
QINFO("Size of u64: %" PRIu64, sizeof(u64));
|
|
QINFO("Size of f32: %lu", sizeof(f32));
|
|
QINFO("Size of f64: %lu", sizeof(f64));
|
|
|
|
QINFO("Creating a List...");
|
|
List *my_list = listCreate();
|
|
QINFO("Pushing to my_list...")
|
|
i32 pushVal = 42;
|
|
listPush(my_list, &pushVal);
|
|
i32 peekVal = *(i32 *)listPeek(my_list);
|
|
|
|
QDEBUG("Peeking value off of my_list: %" PRId32, peekVal);
|
|
|
|
QINFO("Pushing another number to my_list...");
|
|
i32 pushVal2 = 169420;
|
|
listPush(my_list, &pushVal2);
|
|
peekVal = *(i32 *)listPeek(my_list);
|
|
|
|
QDEBUG("Peeking value off of my_list: %" PRId32, peekVal);
|
|
|
|
i32 pushVal3 = 69;
|
|
listPush(my_list, &pushVal3);
|
|
QDEBUG("Peeking a 3rd value off of my_list: %" PRId32, peekVal);
|
|
|
|
i32 popVal = *(i32 *)listPop(my_list);
|
|
QDEBUG("Popped a value off of my_list: %" PRId32, popVal);
|
|
|
|
peekVal = *(i32 *)listPeek(my_list);
|
|
|
|
QDEBUG("Peeking value off of my_list: %" PRId32, peekVal);
|
|
|
|
i32 insertValue = 80085;
|
|
|
|
QINFO("Inserting a value at position 2.");
|
|
listInsertAt(my_list, 2, &insertValue);
|
|
|
|
QDEBUG("Data at position 2 is: %" PRId32, *(i32 *)listDataAt(my_list, 2));
|
|
|
|
QINFO("Removing a value at position 2.");
|
|
listRemoveAt(my_list, 2);
|
|
|
|
QDEBUG("Data at position 2 is now: %" PRId32, *(i32 *)listDataAt(my_list, 2));
|
|
|
|
QINFO("Destorying List...");
|
|
listDestroy(my_list);
|
|
|
|
return 0;
|
|
}
|