Allows for dynamic use of integers only(for now)
This project is licensed under the terms of the MIT license
#include "list.h"
int main(){
list list1 = createList(100);
pushToList(list1, 101);
printList(list1);
deleteList(list1, &list1);
return 0;
}
The above creates a list(list1) containing 1 node which contains the integer value 100.
It then adds a second node to the list containing the value 101.
List1 is then printed to the screen then it is deleted.
node* createList(int data):
returns a pointer to the first node(head) of a new list containing the supplied data
void pushToList(node* head, int data):
adds a new node to the end of the given list containing the supplied data
void printList(node* head):
prints the given list
void printListReverse(node* head):
prints the given list in reverse(strating from the tail)
void popFromList(node* head):
removes the last node from the list(the tail)
int getListLength(node* head):
returns the length of the list(starts counting from 1 not 0)
bool searchList(node* head, int data):
searches in the given list and returns true if a match is found
void pushToListAt(node* head, int data, int index):
adds a node containing the new data to the given list, the new node is added before the node at the given index
int* copyListToArray(node* head):
copies the entire list to an array and returns the the pointer to the start of the integer array
void sortListAscending(node* head):
sorts the given list in ascending order
void deleteList(node* head, node** headPtr):
deallocates every node in the list
void popFromListAt(node* head, int index):
removes the node in the list corresponging to the given index
void mergeLists(node* head1, node* head2):
appends list2 to the tail of list1