Foenix A2650 OS/f Library
Loading...
Searching...
No Matches
list.h
1
/*
2
* list.h
3
*
4
* Created on: Oct 28, 2020
5
* Author: micahbly
6
*
7
* Adaptation for inclusion in A2560 OS/f: Apr 3, 2022
8
*/
9
10
#ifndef LIST_H_
11
#define LIST_H_
12
13
14
/* about this class
15
*
16
* a doubly linked list of pointers to various objects
17
* void* pointers are used for the payload. they may point to:
18
* files
19
* file types
20
* whatever
21
*
22
* Will be used for:
23
*
24
*
25
*** things a list needs to be able to do
26
* create itself
27
* insert a new item at the head
28
* remove an item
29
* sort itself? (probably not needed)
30
* delete an item
31
*
32
*
33
*/
34
35
36
/*****************************************************************************/
37
/* Includes */
38
/*****************************************************************************/
39
40
// project includes
41
//#include "general.h"
42
43
// C includes
44
#include <stdbool.h>
45
46
// A2560 includes
47
#include "a2560k.h"
48
49
50
/*****************************************************************************/
51
/* Macro Definitions */
52
/*****************************************************************************/
53
54
55
56
/*****************************************************************************/
57
/* Enumerations */
58
/*****************************************************************************/
59
60
61
/*****************************************************************************/
62
/* Structs */
63
/*****************************************************************************/
64
65
66
struct
List
67
{
68
List
* next_item_;
69
List
* prev_item_;
70
void
* payload_;
71
};
72
73
74
75
/*****************************************************************************/
76
/* Public Function Prototypes */
77
/*****************************************************************************/
78
79
80
// generates a new list item. Does not add the list item to a list. Use List_AddItem()
81
List
* List_NewItem(
void
* the_payload);
82
83
// destructor
84
void
List_Destroy(
List
** head_item);
85
86
// adds a new list item as the head of the list
87
void
List_AddItem(
List
** head_item,
List
* the_item);
88
89
// adds a new list item after the list_item passed
90
void
List_AddItemAfter(
List
** list_head,
List
* the_new_item,
List
* the_existing_item);
91
92
// adds a new list item before the list_item passed (making itself the head item)
93
void
List_Insert(
List
** head_item,
List
* the_item,
List
* previous_item);
94
95
// removes the specified item from the list (without destroying the list item)
96
void
List_RemoveItem(
List
** head_item,
List
* the_item);
97
98
// iterates through the list looking for the list item that matches the address of the payload object passed
99
List
* List_FindThisObject(
List
** head_item,
void
* the_payload);
100
101
// prints out every item in the list, using the helper function passed
102
List
* List_Print(
List
** list_head,
void
(* print_function)(
void
*));
103
104
// frees the specified item and the data it points to
105
//void List_DeleteItem(List* the_item);
106
107
// Merge Sort. pass a pointer to a function that compares the payload of 2 list items, and returns true if thing 1 > thing 2
108
void
List_InitMergeSort(
List
** list_head,
bool
(* compare_function)(
void
*,
void
*));
109
110
// returns a list item for the first item in the list; returns null if list is empty
111
List
* List_GetFirst(
List
** head_item);
112
113
// returns a list item for the last item in the list; returns null if list is empty
114
List
* List_GetLast(
List
** list_head);
115
116
// for the passed list, return the mid-point list item, given the starting point and ending point desired
117
// use this to do binary searches, etc. if max_item is NULL, will continue until end of list
118
List
* List_GetMidpoint(
List
** list_head,
List
* starting_item,
List
* max_item);
119
120
//*** declarations for test function(s) ***
121
122
123
124
#endif
/* LIST_H_ */
List
Definition:
list.h:67
src
list.h
Generated by
1.9.5