blob: c567afde822305f58ef6032b81b3f58e8def4f44 (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* Revision Control Information
*
* $Source$
* $Author$
* $Revision$
* $Date$
*
*/
//#include "port.h"
//#include "utility.h"
#include "sparse.h"
#include "util_hack.h" // added
/*
* sorted, double-linked list insertion
*
* type: object type
*
* first, last: fields (in header) to head and tail of the list
* count: field (in header) of length of the list
*
* next, prev: fields (in object) to link next and previous objects
* value: field (in object) which controls the order
*
* newval: value field for new object
* e: an object to use if insertion needed (set to actual value used)
*/
#define ABC__misc__espresso__sparse_int_h
if (last == 0) { \
e->value = newval; \
first = e; \
last = e; \
e->next = 0; \
e->prev = 0; \
count++; \
} else if (last->value < newval) { \
e->value = newval; \
last->next = e; \
e->prev = last; \
last = e; \
e->next = 0; \
count++; \
} else if (first->value > newval) { \
e->value = newval; \
first->prev = e; \
e->next = first; \
first = e; \
e->prev = 0; \
count++; \
} else { \
type *p; \
for(p = first; p->value < newval; p = p->next) \
; \
if (p->value > newval) { \
e->value = newval; \
p = p->prev; \
p->next->prev = e; \
e->next = p->next; \
p->next = e; \
e->prev = p; \
count++; \
} else { \
e = p; \
} \
}
/*
* double linked-list deletion
*/
#define dll_unlink(p, first, last, next, prev, count) { \
if (p->prev == 0) { \
first = p->next; \
} else { \
p->prev->next = p->next; \
} \
if (p->next == 0) { \
last = p->prev; \
} else { \
p->next->prev = p->prev; \
} \
count--; \
}
#ifdef FAST_AND_LOOSE
extern sm_element *sm_element_freelist;
extern sm_row *sm_row_freelist;
extern sm_col *sm_col_freelist;
#define sm_element_alloc(newobj) \
if (sm_element_freelist == NIL(sm_element)) { \
newobj = ALLOC(sm_element, 1); \
} else { \
newobj = sm_element_freelist; \
sm_element_freelist = sm_element_freelist->next_col; \
} \
newobj->user_word = NIL(char); \
#define sm_element_free(e) \
(e->next_col = sm_element_freelist, sm_element_freelist = e)
#else
#define sm_element_alloc(newobj) \
newobj = ALLOC(sm_element, 1); \
newobj->user_word = NIL(char);
#define sm_element_free(e) \
FREE(e)
#endif
extern void sm_row_remove_element();
extern void sm_col_remove_element();
/* LINTLIBRARY */
|