src/map/mapper/mapperVec.c File Reference

#include "mapperInt.h"
Include dependency graph for mapperVec.c:

Go to the source code of this file.

Functions

static int Map_NodeVecCompareLevels (Map_Node_t **pp1, Map_Node_t **pp2)
Map_NodeVec_tMap_NodeVecAlloc (int nCap)
void Map_NodeVecFree (Map_NodeVec_t *p)
Map_Node_t ** Map_NodeVecReadArray (Map_NodeVec_t *p)
int Map_NodeVecReadSize (Map_NodeVec_t *p)
void Map_NodeVecGrow (Map_NodeVec_t *p, int nCapMin)
void Map_NodeVecShrink (Map_NodeVec_t *p, int nSizeNew)
void Map_NodeVecClear (Map_NodeVec_t *p)
void Map_NodeVecPush (Map_NodeVec_t *p, Map_Node_t *Entry)
int Map_NodeVecPushUnique (Map_NodeVec_t *p, Map_Node_t *Entry)
Map_Node_tMap_NodeVecPop (Map_NodeVec_t *p)
void Map_NodeVecRemove (Map_NodeVec_t *p, Map_Node_t *Entry)
void Map_NodeVecWriteEntry (Map_NodeVec_t *p, int i, Map_Node_t *Entry)
Map_Node_tMap_NodeVecReadEntry (Map_NodeVec_t *p, int i)
void Map_NodeVecSortByLevel (Map_NodeVec_t *p)

Function Documentation

Map_NodeVec_t* Map_NodeVecAlloc ( int  nCap  ) 

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file mapperVec.c.

00043 {
00044     Map_NodeVec_t * p;
00045     p = ALLOC( Map_NodeVec_t, 1 );
00046     if ( nCap > 0 && nCap < 16 )
00047         nCap = 16;
00048     p->nSize  = 0;
00049     p->nCap   = nCap;
00050     p->pArray = p->nCap? ALLOC( Map_Node_t *, p->nCap ) : NULL;
00051     return p;
00052 }

void Map_NodeVecClear ( Map_NodeVec_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file mapperVec.c.

00151 {
00152     p->nSize = 0;
00153 }

int Map_NodeVecCompareLevels ( Map_Node_t **  pp1,
Map_Node_t **  pp2 
) [static]

CFile****************************************************************

FileName [mapperVec.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - June 1, 2004.]

Revision [

Id
mapperVec.c,v 1.3 2005/01/23 06:59:45 alanmi Exp

] DECLARATIONS ///

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

Synopsis [Comparison procedure for two clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 300 of file mapperVec.c.

00301 {
00302     int Level1 = Map_Regular(*pp1)->Level;
00303     int Level2 = Map_Regular(*pp2)->Level;
00304     if ( Level1 < Level2 )
00305         return -1;
00306     if ( Level1 > Level2 )
00307         return 1;
00308     if ( Map_Regular(*pp1)->Num < Map_Regular(*pp2)->Num )
00309         return -1;
00310     if ( Map_Regular(*pp1)->Num > Map_Regular(*pp2)->Num )
00311         return 1;
00312     return 0; 
00313 }

void Map_NodeVecFree ( Map_NodeVec_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file mapperVec.c.

00066 {
00067     FREE( p->pArray );
00068     FREE( p );
00069 }

void Map_NodeVecGrow ( Map_NodeVec_t p,
int  nCapMin 
)

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file mapperVec.c.

00115 {
00116     if ( p->nCap >= nCapMin )
00117         return;
00118     p->pArray = REALLOC( Map_Node_t *, p->pArray, nCapMin ); 
00119     p->nCap   = nCapMin;
00120 }

Map_Node_t* Map_NodeVecPop ( Map_NodeVec_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 210 of file mapperVec.c.

00211 {
00212     return p->pArray[--p->nSize];
00213 }

void Map_NodeVecPush ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file mapperVec.c.

00167 {
00168     if ( p->nSize == p->nCap )
00169     {
00170         if ( p->nCap < 16 )
00171             Map_NodeVecGrow( p, 16 );
00172         else
00173             Map_NodeVecGrow( p, 2 * p->nCap );
00174     }
00175     p->pArray[p->nSize++] = Entry;
00176 }

int Map_NodeVecPushUnique ( Map_NodeVec_t p,
Map_Node_t 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 189 of file mapperVec.c.

00190 {
00191     int i;
00192     for ( i = 0; i < p->nSize; i++ )
00193         if ( p->pArray[i] == Entry )
00194             return 1;
00195     Map_NodeVecPush( p, Entry );
00196     return 0;
00197 }

Map_Node_t** Map_NodeVecReadArray ( Map_NodeVec_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 82 of file mapperVec.c.

00083 {
00084     return p->pArray;
00085 }

Map_Node_t* Map_NodeVecReadEntry ( Map_NodeVec_t p,
int  i 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file mapperVec.c.

00267 {
00268     assert( i >= 0 && i < p->nSize );
00269     return p->pArray[i];
00270 }

int Map_NodeVecReadSize ( Map_NodeVec_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file mapperVec.c.

00099 {
00100     return p->nSize;
00101 }

void Map_NodeVecRemove ( Map_NodeVec_t p,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 226 of file mapperVec.c.

00227 {
00228     int i;
00229     for ( i = 0; i < p->nSize; i++ )
00230         if ( p->pArray[i] == Entry )
00231             break;
00232     assert( i < p->nSize );
00233     for ( i++; i < p->nSize; i++ )
00234         p->pArray[i-1] = p->pArray[i];
00235     p->nSize--;
00236 }

void Map_NodeVecShrink ( Map_NodeVec_t p,
int  nSizeNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 133 of file mapperVec.c.

00134 {
00135     assert( p->nSize >= nSizeNew );
00136     p->nSize = nSizeNew;
00137 }

void Map_NodeVecSortByLevel ( Map_NodeVec_t p  ) 

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

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file mapperVec.c.

00284 {
00285     qsort( (void *)p->pArray, p->nSize, sizeof(Map_Node_t *), 
00286             (int (*)(const void *, const void *)) Map_NodeVecCompareLevels );
00287 }

void Map_NodeVecWriteEntry ( Map_NodeVec_t p,
int  i,
Map_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file mapperVec.c.

00250 {
00251     assert( i >= 0 && i < p->nSize );
00252     p->pArray[i] = Entry;
00253 }


Generated on Tue Jan 5 12:19:07 2010 for abc70930 by  doxygen 1.6.1