Polymorphic Register Files Simulator
This program aims at simulating the Polymorphic Register Files behaviour, as described in "On Implementability of Polymorphic Register Files"
collection.h
1
/*
2
* Andrea Di Biagio
3
* Politecnico di Milano, 2007
4
*
5
* collections.h
6
* Formal Languages & Compilers Machine, 2007/2008
7
*
8
*/
9
10
#ifndef _COLLECTIONS_H
11
#define _COLLECTIONS_H
12
13
#include <stdlib.h>
14
#include <stdio.h>
15
#include <malloc/malloc.h>
16
#include <string.h>
17
18
/* macros */
19
#define LNEXT(item) ((item)->next)
20
#define LPREV(item) ((item)->prev)
21
#define LDATA(item) ((item)->data)
22
#define SET_DATA(item, _data) ((item)->data = (_data))
23
#define SET_NEXT(item, _next) ((item)->next = (_next))
24
#define SET_PREV(item, _prev) ((item)->prev = (_prev))
25
#ifndef _ALLOC_FUNCTION
26
# define _ALLOC_FUNCTION malloc
27
#endif
28
#ifndef _FREE_FUNCTION
29
# define _FREE_FUNCTION free
30
#endif
31
32
/* a list element */
33
typedef
struct
t_list
34
{
35
void
*data;
36
struct
t_list
*next;
37
struct
t_list
*prev;
38
}
t_list
;
39
40
41
/* add an element `data' to the list `list' at position `pos'. If pos is negative
42
* * , or is larger than the number of elements in the list, the new element is
43
* * added on to the end of the list. Function `addElement' returns a pointer
44
* * to the new head of the list */
45
extern
t_list
* addElement(
t_list
*list,
void
* data,
int
pos);
46
47
/* add sorted */
48
extern
t_list
* addSorted(
t_list
*list,
void
* data
49
,
int
(*compareFunc)(
void
*a,
void
*b));
50
51
/* add an element to the end of the list */
52
extern
t_list
* addLast(
t_list
*list,
void
* data);
53
54
/* add an element at the beginning of the list */
55
extern
t_list
* addFirst(
t_list
*list,
void
* data);
56
57
/* remove an element at the beginning of the list */
58
extern
t_list
* removeFirst(
t_list
*list);
59
60
/* remove an element from the list */
61
extern
t_list
* removeElement(
t_list
*list,
void
* data);
62
63
/* remove a link from the list `list' */
64
extern
t_list
* removeElementLink(
t_list
*list,
t_list
*element);
65
66
/* find an element inside the list `list'. The current implementation calls the
67
* * CustomfindElement' passing a NULL reference as `func' */
68
extern
t_list
* findElement(
t_list
*list,
void
*data);
69
70
/* find an element inside the list `list'. */
71
extern
t_list
* CustomfindElement(
t_list
*list,
void
*data
72
,
int
(*compareFunc)(
void
*a,
void
*b));
73
74
/* find the position of an `element' inside the `list'. -1 if not found */
75
extern
int
getPosition(
t_list
*list,
t_list
*element);
76
77
/* find the length of `list' */
78
extern
int
getLength(
t_list
*list);
79
80
/* remove all the elements of a list */
81
extern
void
freeList(
t_list
*list);
82
83
/* get the last element of the list. Returns NULL if the list is empty
84
* * or list is a NULL pointer */
85
extern
t_list
* getLastElement(
t_list
*list);
86
87
/* retrieve the list element at position `position' inside the `list'.
88
* * Returns NULL if: the list is empty, the list is a NULL pointer or
89
* * the list holds less than `position' elements. */
90
extern
t_list
* getElementAt(
t_list
*list,
unsigned
int
position);
91
92
/* create a new list with the same elements */
93
extern
t_list
* cloneList(
t_list
*list);
94
95
/* add a list of elements to another list */
96
extern
t_list
* addList(
t_list
*list,
t_list
*elements);
97
98
/* add a list of elements to a set */
99
extern
t_list
* addListToSet(
t_list
*list,
t_list
*elements
100
,
int
(*compareFunc)(
void
*a,
void
*b),
int
*modified);
101
102
103
#endif
t_list
Definition:
collection.h:33
src
collection.h
Generated on Fri Apr 6 2018 15:48:29 for Polymorphic Register Files Simulator by
1.8.11