-
Notifications
You must be signed in to change notification settings - Fork 0
/
linked_lists.h
48 lines (42 loc) · 1.73 KB
/
linked_lists.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef Linked_Lists_H
#define Linked_Lists_H
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
typedef struct ListNode_t
{
void* value;
struct ListNode_t* next;
} ListNode;
typedef struct
{
int itemCount;
ListNode* head; // front of list
size_t dataSize;
} LinkedList;
LinkedList* ll_create(void* values[], const size_t n, const size_t typeSize);
int ll_insert(LinkedList* list, void* value, const int index);
int ll_insert_int(LinkedList* list, int value, const int index);
int ll_insert_str(LinkedList* list, char* value, const int index);
int ll_insert_flt(LinkedList* list, float value, const int index);
int ll_insert_dbl(LinkedList* list, double value, const int index);
int ll_insert_chr(LinkedList* list, char value, const int index);
int ll_print(LinkedList* list, void print(const void*));
int ll_delete(LinkedList* list, const int index);
int ll_reverse(LinkedList* list);
int ll_free(LinkedList* list, void free_item(void*));
struct LibLinkedList_l {
LinkedList* (*create)(void* values[], const size_t n, const size_t typeSize);
int (*insert)(LinkedList* list, void* value, const int index);
int (*insert_int)(LinkedList* list, int value, const int index);
int (*insert_str)(LinkedList* list, char* value, const int index);
int (*insert_flt)(LinkedList* list, float value, const int index);
int (*insert_dbl)(LinkedList* list, double value, const int index);
int (*insert_chr)(LinkedList* list, char value, const int index);
int (*print)(LinkedList* list, void print(const void*));
int (*delete)(LinkedList* list, const int index);
int (*reverse)(LinkedList* list);
int (*free)(LinkedList* list, void free_item(void*));
};
extern const struct LibLinkedList_l LibLinkedList;
#endif