ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
msatVec.c File Reference
#include "msatInt.h"
Include dependency graph for msatVec.c:

Go to the source code of this file.

Functions

Msat_IntVec_tMsat_IntVecAlloc (int nCap)
 FUNCTION DEFINITIONS ///.
 
Msat_IntVec_tMsat_IntVecAllocArray (int *pArray, int nSize)
 
Msat_IntVec_tMsat_IntVecAllocArrayCopy (int *pArray, int nSize)
 
Msat_IntVec_tMsat_IntVecDup (Msat_IntVec_t *pVec)
 
Msat_IntVec_tMsat_IntVecDupArray (Msat_IntVec_t *pVec)
 
void Msat_IntVecFree (Msat_IntVec_t *p)
 
void Msat_IntVecFill (Msat_IntVec_t *p, int nSize, int Entry)
 
int * Msat_IntVecReleaseArray (Msat_IntVec_t *p)
 
int * Msat_IntVecReadArray (Msat_IntVec_t *p)
 
int Msat_IntVecReadSize (Msat_IntVec_t *p)
 
int Msat_IntVecReadEntry (Msat_IntVec_t *p, int i)
 
void Msat_IntVecWriteEntry (Msat_IntVec_t *p, int i, int Entry)
 
int Msat_IntVecReadEntryLast (Msat_IntVec_t *p)
 
void Msat_IntVecGrow (Msat_IntVec_t *p, int nCapMin)
 
void Msat_IntVecShrink (Msat_IntVec_t *p, int nSizeNew)
 
void Msat_IntVecClear (Msat_IntVec_t *p)
 
void Msat_IntVecPush (Msat_IntVec_t *p, int Entry)
 
int Msat_IntVecPushUnique (Msat_IntVec_t *p, int Entry)
 
void Msat_IntVecPushUniqueOrder (Msat_IntVec_t *p, int Entry, int fIncrease)
 
int Msat_IntVecPop (Msat_IntVec_t *p)
 
void Msat_IntVecSort (Msat_IntVec_t *p, int fReverse)
 

Function Documentation

◆ Msat_IntVecAlloc()

Msat_IntVec_t * Msat_IntVecAlloc ( int nCap)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file msatVec.c.

49{
52 if ( nCap > 0 && nCap < 16 )
53 nCap = 16;
54 p->nSize = 0;
55 p->nCap = nCap;
56 p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL;
57 return p;
58}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Cube * p
Definition exorList.c:222
struct Msat_IntVec_t_ Msat_IntVec_t
Definition msat.h:45
Here is the caller graph for this function:

◆ Msat_IntVecAllocArray()

Msat_IntVec_t * Msat_IntVecAllocArray ( int * pArray,
int nSize )

Function*************************************************************

Synopsis [Creates the vector from an integer array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file msatVec.c.

72{
75 p->nSize = nSize;
76 p->nCap = nSize;
77 p->pArray = pArray;
78 return p;
79}

◆ Msat_IntVecAllocArrayCopy()

Msat_IntVec_t * Msat_IntVecAllocArrayCopy ( int * pArray,
int nSize )

Function*************************************************************

Synopsis [Creates the vector from an integer array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file msatVec.c.

93{
96 p->nSize = nSize;
97 p->nCap = nSize;
98 p->pArray = ABC_ALLOC( int, nSize );
99 memcpy( p->pArray, pArray, sizeof(int) * nSize );
100 return p;
101}
char * memcpy()
Here is the call graph for this function:

◆ Msat_IntVecClear()

void Msat_IntVecClear ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file msatVec.c.

336{
337 p->nSize = 0;
338}
Here is the caller graph for this function:

◆ Msat_IntVecDup()

Msat_IntVec_t * Msat_IntVecDup ( Msat_IntVec_t * pVec)

Function*************************************************************

Synopsis [Duplicates the integer array.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file msatVec.c.

115{
117 p = ABC_ALLOC( Msat_IntVec_t, 1 );
118 p->nSize = pVec->nSize;
119 p->nCap = pVec->nCap;
120 p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL;
121 memcpy( p->pArray, pVec->pArray, sizeof(int) * pVec->nSize );
122 return p;
123}
Here is the call graph for this function:

◆ Msat_IntVecDupArray()

Msat_IntVec_t * Msat_IntVecDupArray ( Msat_IntVec_t * pVec)

Function*************************************************************

Synopsis [Transfers the array into another vector.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file msatVec.c.

137{
139 p = ABC_ALLOC( Msat_IntVec_t, 1 );
140 p->nSize = pVec->nSize;
141 p->nCap = pVec->nCap;
142 p->pArray = pVec->pArray;
143 pVec->nSize = 0;
144 pVec->nCap = 0;
145 pVec->pArray = NULL;
146 return p;
147}

◆ Msat_IntVecFill()

void Msat_IntVecFill ( Msat_IntVec_t * p,
int nSize,
int Entry )

Function*************************************************************

Synopsis [Fills the vector with given number of entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file msatVec.c.

178{
179 int i;
180 Msat_IntVecGrow( p, nSize );
181 p->nSize = nSize;
182 for ( i = 0; i < p->nSize; i++ )
183 p->pArray[i] = Entry;
184}
void Msat_IntVecGrow(Msat_IntVec_t *p, int nCapMin)
Definition msatVec.c:299
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_IntVecFree()

void Msat_IntVecFree ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file msatVec.c.

161{
162 ABC_FREE( p->pArray );
163 ABC_FREE( p );
164}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Msat_IntVecGrow()

void Msat_IntVecGrow ( Msat_IntVec_t * p,
int nCapMin )

Function*************************************************************

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 299 of file msatVec.c.

300{
301 if ( p->nCap >= nCapMin )
302 return;
303 p->pArray = ABC_REALLOC( int, p->pArray, nCapMin );
304 p->nCap = nCapMin;
305}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
Here is the caller graph for this function:

◆ Msat_IntVecPop()

int Msat_IntVecPop ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis [Returns the last entry and removes it from the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file msatVec.c.

426{
427 assert( p->nSize > 0 );
428 return p->pArray[--p->nSize];
429}
#define assert(ex)
Definition util_old.h:213

◆ Msat_IntVecPush()

void Msat_IntVecPush ( Msat_IntVec_t * p,
int Entry )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 351 of file msatVec.c.

352{
353 if ( p->nSize == p->nCap )
354 {
355 if ( p->nCap < 16 )
356 Msat_IntVecGrow( p, 16 );
357 else
358 Msat_IntVecGrow( p, 2 * p->nCap );
359 }
360 p->pArray[p->nSize++] = Entry;
361}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_IntVecPushUnique()

int Msat_IntVecPushUnique ( Msat_IntVec_t * p,
int Entry )

Function*************************************************************

Synopsis [Add the element while ensuring uniqueness.]

Description [Returns 1 if the element was found, and 0 if it was new. ]

SideEffects []

SeeAlso []

Definition at line 374 of file msatVec.c.

375{
376 int i;
377 for ( i = 0; i < p->nSize; i++ )
378 if ( p->pArray[i] == Entry )
379 return 1;
380 Msat_IntVecPush( p, Entry );
381 return 0;
382}
void Msat_IntVecPush(Msat_IntVec_t *p, int Entry)
Definition msatVec.c:351
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_IntVecPushUniqueOrder()

void Msat_IntVecPushUniqueOrder ( Msat_IntVec_t * p,
int Entry,
int fIncrease )

Function*************************************************************

Synopsis [Inserts the element while sorting in the increasing order.]

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file msatVec.c.

396{
397 int Entry1, Entry2;
398 int i;
399 Msat_IntVecPushUnique( p, Entry );
400 // find the p of the node
401 for ( i = p->nSize-1; i > 0; i-- )
402 {
403 Entry1 = p->pArray[i ];
404 Entry2 = p->pArray[i-1];
405 if (( fIncrease && Entry1 >= Entry2) ||
406 (!fIncrease && Entry1 <= Entry2) )
407 break;
408 p->pArray[i ] = Entry2;
409 p->pArray[i-1] = Entry1;
410 }
411}
int Msat_IntVecPushUnique(Msat_IntVec_t *p, int Entry)
Definition msatVec.c:374
Here is the call graph for this function:

◆ Msat_IntVecReadArray()

int * Msat_IntVecReadArray ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file msatVec.c.

218{
219 return p->pArray;
220}
Here is the caller graph for this function:

◆ Msat_IntVecReadEntry()

int Msat_IntVecReadEntry ( Msat_IntVec_t * p,
int i )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file msatVec.c.

250{
251 assert( i >= 0 && i < p->nSize );
252 return p->pArray[i];
253}
Here is the caller graph for this function:

◆ Msat_IntVecReadEntryLast()

int Msat_IntVecReadEntryLast ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file msatVec.c.

284{
285 return p->pArray[p->nSize-1];
286}

◆ Msat_IntVecReadSize()

int Msat_IntVecReadSize ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 233 of file msatVec.c.

234{
235 return p->nSize;
236}
Here is the caller graph for this function:

◆ Msat_IntVecReleaseArray()

int * Msat_IntVecReleaseArray ( Msat_IntVec_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file msatVec.c.

198{
199 int * pArray = p->pArray;
200 p->nCap = 0;
201 p->nSize = 0;
202 p->pArray = NULL;
203 return pArray;
204}

◆ Msat_IntVecShrink()

void Msat_IntVecShrink ( Msat_IntVec_t * p,
int nSizeNew )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 318 of file msatVec.c.

319{
320 assert( p->nSize >= nSizeNew );
321 p->nSize = nSizeNew;
322}
Here is the caller graph for this function:

◆ Msat_IntVecSort()

void Msat_IntVecSort ( Msat_IntVec_t * p,
int fReverse )

Function*************************************************************

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file msatVec.c.

443{
444 if ( fReverse )
445 qsort( (void *)p->pArray, (size_t)p->nSize, sizeof(int),
446 (int (*)(const void *, const void *)) Msat_IntVecSortCompare2 );
447 else
448 qsort( (void *)p->pArray, (size_t)p->nSize, sizeof(int),
449 (int (*)(const void *, const void *)) Msat_IntVecSortCompare1 );
450}
Here is the caller graph for this function:

◆ Msat_IntVecWriteEntry()

void Msat_IntVecWriteEntry ( Msat_IntVec_t * p,
int i,
int Entry )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file msatVec.c.

267{
268 assert( i >= 0 && i < p->nSize );
269 p->pArray[i] = Entry;
270}