-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
65 lines (49 loc) · 1.61 KB
/
list.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* list.h */
#ifndef __LIST_H
#define __LIST_H
#include "common.h"
#include "buffer.h"
/* Begin type customisation for lists */
#include "EXTERN.h"
#include "perl.h"
/* The type of object handled */
#define list_ITY SV *
/* The size of list_ITY */
#define list_ISZ (sizeof (list_ITY))
/* Given a list_ITY how do you find the next one? */
#define list_NEXT(v) ((list_ITY) SvANY(v))
/* Compare two items to determine ordering; a and b are of type
* list_ITY *
*/
#define list_CMP(a, b) (memcmp((a), (b), list_ISZ))
/* End type customisation */
typedef buffer list;
#define list_init(l, sz) \
buffer_init(l, sz * list_ISZ, 100 * list_ISZ)
#define list_used(l) \
(buffer_used(l) / list_ISZ)
#define list_size(l) \
(buffer_size(l) / list_ISZ)
#define list_delete(l) \
buffer_delete(l)
/* Get pointer to list array */
#define list_ar(l) \
((list_ITY *)(l)->buf)
typedef void (*list_callback)(list_ITY v, const void *p);
int list_append(list *l, const list_ITY p);
/* Return the location of the first difference between two lists
* scanning from the end. The value returned is the offset from
* the end of each list (i.e. -1 .. -(list size)) of the first
* difference or 0 if the lists are the same.
*/
#if 0
long list_cmp(const list *a, const list *b);
void list_diff(const list *a, const list *b,
const void *p,
list_callback added, list_callback removed);
#endif
int list_build(list *l, const list_ITY v, size_t sz);
void list_sort(list *l);
long list_true_diff(list *a, list *b, const void *p,
list_callback added, list_callback removed);
#endif /* __LIST_H */