abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sparse_int.h
Go to the documentation of this file.
1 /*
2  * Revision Control Information
3  *
4  * $Source$
5  * $Author$
6  * $Revision$
7  * $Date$
8  *
9  */
10 //#include "port.h"
11 //#include "utility.h"
12 #include "sparse.h"
13 
14 #include "util_hack.h" // added
15 
16 
17 
18 /*
19  * sorted, double-linked list insertion
20  *
21  * type: object type
22  *
23  * first, last: fields (in header) to head and tail of the list
24  * count: field (in header) of length of the list
25  *
26  * next, prev: fields (in object) to link next and previous objects
27  * value: field (in object) which controls the order
28  *
29  * newval: value field for new object
30  * e: an object to use if insertion needed (set to actual value used)
31  */
32 
33 #define ABC__misc__espresso__sparse_int_h
34  if (last == 0) { \
35  e->value = newval; \
36  first = e; \
37  last = e; \
38  e->next = 0; \
39  e->prev = 0; \
40  count++; \
41  } else if (last->value < newval) { \
42  e->value = newval; \
43  last->next = e; \
44  e->prev = last; \
45  last = e; \
46  e->next = 0; \
47  count++; \
48  } else if (first->value > newval) { \
49  e->value = newval; \
50  first->prev = e; \
51  e->next = first; \
52  first = e; \
53  e->prev = 0; \
54  count++; \
55  } else { \
56  type *p; \
57  for(p = first; p->value < newval; p = p->next) \
58  ; \
59  if (p->value > newval) { \
60  e->value = newval; \
61  p = p->prev; \
62  p->next->prev = e; \
63  e->next = p->next; \
64  p->next = e; \
65  e->prev = p; \
66  count++; \
67  } else { \
68  e = p; \
69  } \
70  }
71 
72 
73 /*
74  * double linked-list deletion
75  */
76 #define dll_unlink(p, first, last, next, prev, count) { \
77  if (p->prev == 0) { \
78  first = p->next; \
79  } else { \
80  p->prev->next = p->next; \
81  } \
82  if (p->next == 0) { \
83  last = p->prev; \
84  } else { \
85  p->next->prev = p->prev; \
86  } \
87  count--; \
88 }
89 
90 
91 #ifdef FAST_AND_LOOSE
92 extern sm_element *sm_element_freelist;
93 extern sm_row *sm_row_freelist;
94 extern sm_col *sm_col_freelist;
95 
96 #define sm_element_alloc(newobj) \
97  if (sm_element_freelist == NIL(sm_element)) { \
98  newobj = ALLOC(sm_element, 1); \
99  } else { \
100  newobj = sm_element_freelist; \
101  sm_element_freelist = sm_element_freelist->next_col; \
102  } \
103  newobj->user_word = NIL(char); \
104 
105 #define sm_element_free(e) \
106  (e->next_col = sm_element_freelist, sm_element_freelist = e)
107 
108 #else
109 
110 #define sm_element_alloc(newobj) \
111  newobj = ALLOC(sm_element, 1); \
112  newobj->user_word = NIL(char);
113 #define sm_element_free(e) \
114  FREE(e)
115 #endif
116 
117 
118 extern void sm_row_remove_element();
119 extern void sm_col_remove_element();
120 
121 /* LINTLIBRARY */
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sm_col_remove_element()
for(p=first;p->value< newval;p=p->next)
if(last==0)
Definition: sparse_int.h:34
typedefABC_NAMESPACE_HEADER_START struct sm_element_struct sm_element
Definition: sparse.h:21
void sm_row_remove_element()