abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fxuList.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [fxuList.c]
4 
5  PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]
6 
7  Synopsis [Operations on lists.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 1.0. Started - February 1, 2003.]
14 
15  Revision [$Id: fxuList.c,v 1.0 2003/02/01 00:00:00 alanmi Exp $]
16 
17 ***********************************************************************/
18 
19 #include "fxuInt.h"
20 
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 /// DECLARATIONS ///
26 ////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// FUNCTION DEFINITIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 // matrix -> var
33 
34 /**Function*************************************************************
35 
36  Synopsis []
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  Fxu_ListVar * pList = &p->lVars;
48  if ( pList->pHead == NULL )
49  {
50  pList->pHead = pLink;
51  pList->pTail = pLink;
52  pLink->pPrev = NULL;
53  pLink->pNext = NULL;
54  }
55  else
56  {
57  pLink->pNext = NULL;
58  pList->pTail->pNext = pLink;
59  pLink->pPrev = pList->pTail;
60  pList->pTail = pLink;
61  }
62  pList->nItems++;
63 }
64 
65 /**Function*************************************************************
66 
67  Synopsis []
68 
69  Description []
70 
71  SideEffects []
72 
73  SeeAlso []
74 
75 ***********************************************************************/
77 {
78  Fxu_ListVar * pList = &p->lVars;
79  if ( pList->pHead == pLink )
80  pList->pHead = pLink->pNext;
81  if ( pList->pTail == pLink )
82  pList->pTail = pLink->pPrev;
83  if ( pLink->pPrev )
84  pLink->pPrev->pNext = pLink->pNext;
85  if ( pLink->pNext )
86  pLink->pNext->pPrev = pLink->pPrev;
87  pList->nItems--;
88 }
89 
90 
91 // matrix -> cube
92 
93 /**Function*************************************************************
94 
95  Synopsis []
96 
97  Description []
98 
99  SideEffects []
100 
101  SeeAlso []
102 
103 ***********************************************************************/
105 {
106  Fxu_ListCube * pList = &p->lCubes;
107  if ( pList->pHead == NULL )
108  {
109  pList->pHead = pLink;
110  pList->pTail = pLink;
111  pLink->pPrev = NULL;
112  pLink->pNext = NULL;
113  }
114  else
115  {
116  pLink->pNext = NULL;
117  pList->pTail->pNext = pLink;
118  pLink->pPrev = pList->pTail;
119  pList->pTail = pLink;
120  }
121  pList->nItems++;
122 }
123 
124 /**Function*************************************************************
125 
126  Synopsis []
127 
128  Description []
129 
130  SideEffects []
131 
132  SeeAlso []
133 
134 ***********************************************************************/
136 {
137  Fxu_ListCube * pList = &p->lCubes;
138  if ( pList->pHead == pLink )
139  pList->pHead = pLink->pNext;
140  if ( pList->pTail == pLink )
141  pList->pTail = pLink->pPrev;
142  if ( pLink->pPrev )
143  pLink->pPrev->pNext = pLink->pNext;
144  if ( pLink->pNext )
145  pLink->pNext->pPrev = pLink->pPrev;
146  pList->nItems--;
147 }
148 
149 
150 // matrix -> single
151 
152 /**Function*************************************************************
153 
154  Synopsis []
155 
156  Description []
157 
158  SideEffects []
159 
160  SeeAlso []
161 
162 ***********************************************************************/
164 {
165  Fxu_ListSingle * pList = &p->lSingles;
166  if ( pList->pHead == NULL )
167  {
168  pList->pHead = pLink;
169  pList->pTail = pLink;
170  pLink->pPrev = NULL;
171  pLink->pNext = NULL;
172  }
173  else
174  {
175  pLink->pNext = NULL;
176  pList->pTail->pNext = pLink;
177  pLink->pPrev = pList->pTail;
178  pList->pTail = pLink;
179  }
180  pList->nItems++;
181 }
182 
183 /**Function*************************************************************
184 
185  Synopsis []
186 
187  Description []
188 
189  SideEffects []
190 
191  SeeAlso []
192 
193 ***********************************************************************/
195 {
196  Fxu_ListSingle * pList = &p->lSingles;
197  if ( pList->pHead == pLink )
198  pList->pHead = pLink->pNext;
199  if ( pList->pTail == pLink )
200  pList->pTail = pLink->pPrev;
201  if ( pLink->pPrev )
202  pLink->pPrev->pNext = pLink->pNext;
203  if ( pLink->pNext )
204  pLink->pNext->pPrev = pLink->pPrev;
205  pList->nItems--;
206 }
207 
208 
209 // table -> divisor
210 
211 /**Function*************************************************************
212 
213  Synopsis []
214 
215  Description []
216 
217  SideEffects []
218 
219  SeeAlso []
220 
221 ***********************************************************************/
223 {
224  Fxu_ListDouble * pList = &(p->pTable[pLink->Key]);
225  if ( pList->pHead == NULL )
226  {
227  pList->pHead = pLink;
228  pList->pTail = pLink;
229  pLink->pPrev = NULL;
230  pLink->pNext = NULL;
231  }
232  else
233  {
234  pLink->pNext = NULL;
235  pList->pTail->pNext = pLink;
236  pLink->pPrev = pList->pTail;
237  pList->pTail = pLink;
238  }
239  pList->nItems++;
240  p->nDivs++;
241 }
242 
243 /**Function*************************************************************
244 
245  Synopsis []
246 
247  Description []
248 
249  SideEffects []
250 
251  SeeAlso []
252 
253 ***********************************************************************/
255 {
256  Fxu_ListDouble * pList = &(p->pTable[pLink->Key]);
257  if ( pList->pHead == pLink )
258  pList->pHead = pLink->pNext;
259  if ( pList->pTail == pLink )
260  pList->pTail = pLink->pPrev;
261  if ( pLink->pPrev )
262  pLink->pPrev->pNext = pLink->pNext;
263  if ( pLink->pNext )
264  pLink->pNext->pPrev = pLink->pPrev;
265  pList->nItems--;
266  p->nDivs--;
267 }
268 
269 
270 // cube -> literal
271 
272 /**Function*************************************************************
273 
274  Synopsis []
275 
276  Description []
277 
278  SideEffects []
279 
280  SeeAlso []
281 
282 ***********************************************************************/
283 void Fxu_ListCubeAddLiteral( Fxu_Cube * pCube, Fxu_Lit * pLink )
284 {
285  Fxu_ListLit * pList = &(pCube->lLits);
286  if ( pList->pHead == NULL )
287  {
288  pList->pHead = pLink;
289  pList->pTail = pLink;
290  pLink->pHPrev = NULL;
291  pLink->pHNext = NULL;
292  }
293  else
294  {
295  pLink->pHNext = NULL;
296  pList->pTail->pHNext = pLink;
297  pLink->pHPrev = pList->pTail;
298  pList->pTail = pLink;
299  }
300  pList->nItems++;
301 }
302 
303 /**Function*************************************************************
304 
305  Synopsis []
306 
307  Description []
308 
309  SideEffects []
310 
311  SeeAlso []
312 
313 ***********************************************************************/
314 void Fxu_ListCubeDelLiteral( Fxu_Cube * pCube, Fxu_Lit * pLink )
315 {
316  Fxu_ListLit * pList = &(pCube->lLits);
317  if ( pList->pHead == pLink )
318  pList->pHead = pLink->pHNext;
319  if ( pList->pTail == pLink )
320  pList->pTail = pLink->pHPrev;
321  if ( pLink->pHPrev )
322  pLink->pHPrev->pHNext = pLink->pHNext;
323  if ( pLink->pHNext )
324  pLink->pHNext->pHPrev = pLink->pHPrev;
325  pList->nItems--;
326 }
327 
328 
329 // var -> literal
330 
331 /**Function*************************************************************
332 
333  Synopsis []
334 
335  Description []
336 
337  SideEffects []
338 
339  SeeAlso []
340 
341 ***********************************************************************/
342 void Fxu_ListVarAddLiteral( Fxu_Var * pVar, Fxu_Lit * pLink )
343 {
344  Fxu_ListLit * pList = &(pVar->lLits);
345  if ( pList->pHead == NULL )
346  {
347  pList->pHead = pLink;
348  pList->pTail = pLink;
349  pLink->pVPrev = NULL;
350  pLink->pVNext = NULL;
351  }
352  else
353  {
354  pLink->pVNext = NULL;
355  pList->pTail->pVNext = pLink;
356  pLink->pVPrev = pList->pTail;
357  pList->pTail = pLink;
358  }
359  pList->nItems++;
360 }
361 
362 /**Function*************************************************************
363 
364  Synopsis []
365 
366  Description []
367 
368  SideEffects []
369 
370  SeeAlso []
371 
372 ***********************************************************************/
373 void Fxu_ListVarDelLiteral( Fxu_Var * pVar, Fxu_Lit * pLink )
374 {
375  Fxu_ListLit * pList = &(pVar->lLits);
376  if ( pList->pHead == pLink )
377  pList->pHead = pLink->pVNext;
378  if ( pList->pTail == pLink )
379  pList->pTail = pLink->pVPrev;
380  if ( pLink->pVPrev )
381  pLink->pVPrev->pVNext = pLink->pVNext;
382  if ( pLink->pVNext )
383  pLink->pVNext->pVPrev = pLink->pVPrev;
384  pList->nItems--;
385 }
386 
387 
388 
389 // divisor -> pair
390 
391 /**Function*************************************************************
392 
393  Synopsis []
394 
395  Description []
396 
397  SideEffects []
398 
399  SeeAlso []
400 
401 ***********************************************************************/
403 {
404  Fxu_ListPair * pList = &pDiv->lPairs;
405  if ( pList->pHead == NULL )
406  {
407  pList->pHead = pLink;
408  pList->pTail = pLink;
409  pLink->pDPrev = NULL;
410  pLink->pDNext = NULL;
411  }
412  else
413  {
414  pLink->pDNext = NULL;
415  pList->pTail->pDNext = pLink;
416  pLink->pDPrev = pList->pTail;
417  pList->pTail = pLink;
418  }
419  pList->nItems++;
420 }
421 
422 /**Function*************************************************************
423 
424  Synopsis []
425 
426  Description []
427 
428  SideEffects []
429 
430  SeeAlso []
431 
432 ***********************************************************************/
434 {
435  Fxu_ListPair * pList = &pDiv->lPairs;
436  if ( pList->pHead == NULL )
437  {
438  pList->pHead = pLink;
439  pList->pTail = pLink;
440  pLink->pDPrev = NULL;
441  pLink->pDNext = NULL;
442  }
443  else
444  {
445  pLink->pDPrev = NULL;
446  pList->pHead->pDPrev = pLink;
447  pLink->pDNext = pList->pHead;
448  pList->pHead = pLink;
449  }
450  pList->nItems++;
451 }
452 
453 /**Function*************************************************************
454 
455  Synopsis [Adds the entry in the middle of the list after the spot.]
456 
457  Description [Assumes that spot points to the link, after which the given
458  link should be added. Spot cannot be NULL or the tail of the list.
459  Therefore, the head and the tail of the list are not changed.]
460 
461  SideEffects []
462 
463  SeeAlso []
464 
465 ***********************************************************************/
466 void Fxu_ListDoubleAddPairMiddle( Fxu_Double * pDiv, Fxu_Pair * pSpot, Fxu_Pair * pLink )
467 {
468  Fxu_ListPair * pList = &pDiv->lPairs;
469  assert( pSpot );
470  assert( pSpot != pList->pTail );
471  pLink->pDPrev = pSpot;
472  pLink->pDNext = pSpot->pDNext;
473  pLink->pDPrev->pDNext = pLink;
474  pLink->pDNext->pDPrev = pLink;
475  pList->nItems++;
476 }
477 
478 /**Function*************************************************************
479 
480  Synopsis []
481 
482  Description []
483 
484  SideEffects []
485 
486  SeeAlso []
487 
488 ***********************************************************************/
490 {
491  Fxu_ListPair * pList = &pDiv->lPairs;
492  if ( pList->pHead == pLink )
493  pList->pHead = pLink->pDNext;
494  if ( pList->pTail == pLink )
495  pList->pTail = pLink->pDPrev;
496  if ( pLink->pDPrev )
497  pLink->pDPrev->pDNext = pLink->pDNext;
498  if ( pLink->pDNext )
499  pLink->pDNext->pDPrev = pLink->pDPrev;
500  pList->nItems--;
501 }
502 
503 /**Function*************************************************************
504 
505  Synopsis []
506 
507  Description []
508 
509  SideEffects []
510 
511  SeeAlso []
512 
513 ***********************************************************************/
514 void Fxu_ListDoubleAddPairPlace( Fxu_Double * pDiv, Fxu_Pair * pPair, Fxu_Pair * pPairSpot )
515 {
516  printf( "Fxu_ListDoubleAddPairPlace() is called!\n" );
517 }
518 
519 
520 
521 ////////////////////////////////////////////////////////////////////////
522 /// END OF FILE ///
523 ////////////////////////////////////////////////////////////////////////
524 
525 
527 
void Fxu_ListVarAddLiteral(Fxu_Var *pVar, Fxu_Lit *pLink)
Definition: fxuList.c:342
Definition: fxuInt.h:213
void Fxu_ListMatrixDelCube(Fxu_Matrix *p, Fxu_Cube *pLink)
Definition: fxuList.c:135
Fxu_Var * pPrev
Definition: fxuInt.h:220
Fxu_ListLit lLits
Definition: fxuInt.h:219
void Fxu_ListMatrixDelVariable(Fxu_Matrix *p, Fxu_Var *pLink)
Definition: fxuList.c:76
Fxu_Single * pTail
Definition: fxuInt.h:134
Fxu_Pair * pHead
Definition: fxuInt.h:117
Fxu_Cube * pPrev
Definition: fxuInt.h:207
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Fxu_ListMatrixAddSingle(Fxu_Matrix *p, Fxu_Single *pLink)
Definition: fxuList.c:163
Fxu_Double * pPrev
Definition: fxuInt.h:261
Fxu_Cube * pTail
Definition: fxuInt.h:94
Fxu_Lit * pHead
Definition: fxuInt.h:109
Fxu_ListPair lPairs
Definition: fxuInt.h:260
ABC_NAMESPACE_IMPL_START void Fxu_ListMatrixAddVariable(Fxu_Matrix *p, Fxu_Var *pLink)
DECLARATIONS ///.
Definition: fxuList.c:45
int nItems
Definition: fxuInt.h:127
Fxu_Lit * pHNext
Definition: fxuInt.h:233
void Fxu_ListMatrixDelSingle(Fxu_Matrix *p, Fxu_Single *pLink)
Definition: fxuList.c:194
Fxu_Lit * pVNext
Definition: fxuInt.h:235
void Fxu_ListMatrixAddCube(Fxu_Matrix *p, Fxu_Cube *pLink)
Definition: fxuList.c:104
Fxu_Single * pHead
Definition: fxuInt.h:133
Fxu_Single * pPrev
Definition: fxuInt.h:274
Fxu_Var * pHead
Definition: fxuInt.h:101
Fxu_ListLit lLits
Definition: fxuInt.h:206
Fxu_Pair * pDPrev
Definition: fxuInt.h:249
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Fxu_Lit * pVPrev
Definition: fxuInt.h:234
int nItems
Definition: fxuInt.h:135
void Fxu_ListVarDelLiteral(Fxu_Var *pVar, Fxu_Lit *pLink)
Definition: fxuList.c:373
void Fxu_ListDoubleDelPair(Fxu_Double *pDiv, Fxu_Pair *pLink)
Definition: fxuList.c:489
Fxu_Single * pNext
Definition: fxuInt.h:275
Fxu_Cube * pNext
Definition: fxuInt.h:208
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
void Fxu_ListCubeDelLiteral(Fxu_Cube *pCube, Fxu_Lit *pLink)
Definition: fxuList.c:314
int nItems
Definition: fxuInt.h:103
Fxu_Lit * pTail
Definition: fxuInt.h:110
void Fxu_ListDoubleAddPairMiddle(Fxu_Double *pDiv, Fxu_Pair *pSpot, Fxu_Pair *pLink)
Definition: fxuList.c:466
Fxu_Double * pHead
Definition: fxuInt.h:125
Fxu_Var * pTail
Definition: fxuInt.h:102
void Fxu_ListCubeAddLiteral(Fxu_Cube *pCube, Fxu_Lit *pLink)
Definition: fxuList.c:283
void Fxu_ListDoubleAddPairPlace(Fxu_Double *pDiv, Fxu_Pair *pPair, Fxu_Pair *pPairSpot)
Definition: fxuList.c:514
void Fxu_ListTableAddDivisor(Fxu_Matrix *p, Fxu_Double *pLink)
Definition: fxuList.c:222
Fxu_Cube * pHead
Definition: fxuInt.h:93
int nItems
Definition: fxuInt.h:95
unsigned Key
Definition: fxuInt.h:259
int nItems
Definition: fxuInt.h:111
void Fxu_ListTableDelDivisor(Fxu_Matrix *p, Fxu_Double *pLink)
Definition: fxuList.c:254
void Fxu_ListDoubleAddPairLast(Fxu_Double *pDiv, Fxu_Pair *pLink)
Definition: fxuList.c:402
int nItems
Definition: fxuInt.h:119
#define assert(ex)
Definition: util_old.h:213
Fxu_Pair * pDNext
Definition: fxuInt.h:250
Fxu_Var * pNext
Definition: fxuInt.h:221
typedefABC_NAMESPACE_HEADER_START struct FxuMatrix Fxu_Matrix
INCLUDES ///.
Definition: fxuInt.h:63
void Fxu_ListDoubleAddPairFirst(Fxu_Double *pDiv, Fxu_Pair *pLink)
Definition: fxuList.c:433
Definition: fxuInt.h:226
Fxu_Lit * pHPrev
Definition: fxuInt.h:232
Fxu_Pair * pTail
Definition: fxuInt.h:118
Fxu_Double * pNext
Definition: fxuInt.h:262
Fxu_Double * pTail
Definition: fxuInt.h:126