src/misc/vec/vecFlt.h File Reference

#include <stdio.h>
Include dependency graph for vecFlt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Vec_Flt_t_

Defines

#define Vec_FltForEachEntry(vVec, Entry, i)   for ( i = 0; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
#define Vec_FltForEachEntryStart(vVec, Entry, i, Start)   for ( i = Start; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
#define Vec_FltForEachEntryStartStop(vVec, Entry, i, Start, Stop)   for ( i = Start; (i < Stop) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
#define Vec_FltForEachEntryReverse(vVec, pEntry, i)   for ( i = Vec_FltSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_FltEntry(vVec, i)), 1); i-- )

Typedefs

typedef struct Vec_Flt_t_ Vec_Flt_t

Functions

static Vec_Flt_tVec_FltAlloc (int nCap)
static Vec_Flt_tVec_FltStart (int nSize)
static Vec_Flt_tVec_FltAllocArray (float *pArray, int nSize)
static Vec_Flt_tVec_FltAllocArrayCopy (float *pArray, int nSize)
static Vec_Flt_tVec_FltDup (Vec_Flt_t *pVec)
static Vec_Flt_tVec_FltDupArray (Vec_Flt_t *pVec)
static void Vec_FltFree (Vec_Flt_t *p)
static float * Vec_FltReleaseArray (Vec_Flt_t *p)
static float * Vec_FltArray (Vec_Flt_t *p)
static int Vec_FltSize (Vec_Flt_t *p)
static float Vec_FltEntry (Vec_Flt_t *p, int i)
static void Vec_FltWriteEntry (Vec_Flt_t *p, int i, float Entry)
static void Vec_FltAddToEntry (Vec_Flt_t *p, int i, float Addition)
static float Vec_FltEntryLast (Vec_Flt_t *p)
static void Vec_FltGrow (Vec_Flt_t *p, int nCapMin)
static void Vec_FltFill (Vec_Flt_t *p, int nSize, float Entry)
static void Vec_FltFillExtra (Vec_Flt_t *p, int nSize, float Entry)
static void Vec_FltShrink (Vec_Flt_t *p, int nSizeNew)
static void Vec_FltClear (Vec_Flt_t *p)
static void Vec_FltPush (Vec_Flt_t *p, float Entry)
static void Vec_FltPushOrder (Vec_Flt_t *p, float Entry)
static int Vec_FltPushUnique (Vec_Flt_t *p, float Entry)
static float Vec_FltPop (Vec_Flt_t *p)
static int Vec_FltFind (Vec_Flt_t *p, float Entry)
static int Vec_FltRemove (Vec_Flt_t *p, float Entry)
static int Vec_FltSortCompare1 (float *pp1, float *pp2)
static int Vec_FltSortCompare2 (float *pp1, float *pp2)
static void Vec_FltSort (Vec_Flt_t *p, int fReverse)

Define Documentation

#define Vec_FltForEachEntry ( vVec,
Entry,
 )     for ( i = 0; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )

MACRO DEFINITIONS ///

Definition at line 50 of file vecFlt.h.

#define Vec_FltForEachEntryReverse ( vVec,
pEntry,
 )     for ( i = Vec_FltSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_FltEntry(vVec, i)), 1); i-- )

Definition at line 56 of file vecFlt.h.

#define Vec_FltForEachEntryStart ( vVec,
Entry,
i,
Start   )     for ( i = Start; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )

Definition at line 52 of file vecFlt.h.

#define Vec_FltForEachEntryStartStop ( vVec,
Entry,
i,
Start,
Stop   )     for ( i = Start; (i < Stop) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )

Definition at line 54 of file vecFlt.h.


Typedef Documentation

typedef struct Vec_Flt_t_ Vec_Flt_t

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

FileName [vecFlt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Resizable arrays.]

Synopsis [Resizable arrays of floats.]

Author [Aaron P. Hurst]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
vecInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] INCLUDES /// PARAMETERS /// BASIC TYPES ///

Definition at line 38 of file vecFlt.h.


Function Documentation

static void Vec_FltAddToEntry ( Vec_Flt_t p,
int  i,
float  Addition 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 309 of file vecFlt.h.

00310 {
00311     assert( i >= 0 && i < p->nSize );
00312     p->pArray[i] += Addition;
00313 }

static Vec_Flt_t* Vec_FltAlloc ( int  nCap  )  [inline, static]

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file vecFlt.h.

00075 {
00076     Vec_Flt_t * p;
00077     p = ALLOC( Vec_Flt_t, 1 );
00078     if ( nCap > 0 && nCap < 16 )
00079         nCap = 16;
00080     p->nSize  = 0;
00081     p->nCap   = nCap;
00082     p->pArray = p->nCap? ALLOC( float, p->nCap ) : NULL;
00083     return p;
00084 }

static Vec_Flt_t* Vec_FltAllocArray ( float *  pArray,
int  nSize 
) [inline, static]

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

Synopsis [Creates the vector from a float array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file vecFlt.h.

00118 {
00119     Vec_Flt_t * p;
00120     p = ALLOC( Vec_Flt_t, 1 );
00121     p->nSize  = nSize;
00122     p->nCap   = nSize;
00123     p->pArray = pArray;
00124     return p;
00125 }

static Vec_Flt_t* Vec_FltAllocArrayCopy ( float *  pArray,
int  nSize 
) [inline, static]

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

Synopsis [Creates the vector from a float array of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 138 of file vecFlt.h.

00139 {
00140     Vec_Flt_t * p;
00141     p = ALLOC( Vec_Flt_t, 1 );
00142     p->nSize  = nSize;
00143     p->nCap   = nSize;
00144     p->pArray = ALLOC( float, nSize );
00145     memcpy( p->pArray, pArray, sizeof(float) * nSize );
00146     return p;
00147 }

static float* Vec_FltArray ( Vec_Flt_t p  )  [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 243 of file vecFlt.h.

00244 {
00245     return p->pArray;
00246 }

static void Vec_FltClear ( Vec_Flt_t p  )  [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 420 of file vecFlt.h.

00421 {
00422     p->nSize = 0;
00423 }

static Vec_Flt_t* Vec_FltDup ( Vec_Flt_t pVec  )  [inline, static]

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

Synopsis [Duplicates the float array.]

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file vecFlt.h.

00161 {
00162     Vec_Flt_t * p;
00163     p = ALLOC( Vec_Flt_t, 1 );
00164     p->nSize  = pVec->nSize;
00165     p->nCap   = pVec->nCap;
00166     p->pArray = p->nCap? ALLOC( float, p->nCap ) : NULL;
00167     memcpy( p->pArray, pVec->pArray, sizeof(float) * pVec->nSize );
00168     return p;
00169 }

static Vec_Flt_t* Vec_FltDupArray ( Vec_Flt_t pVec  )  [inline, static]

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

Synopsis [Transfers the array into another vector.]

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file vecFlt.h.

00183 {
00184     Vec_Flt_t * p;
00185     p = ALLOC( Vec_Flt_t, 1 );
00186     p->nSize  = pVec->nSize;
00187     p->nCap   = pVec->nCap;
00188     p->pArray = pVec->pArray;
00189     pVec->nSize  = 0;
00190     pVec->nCap   = 0;
00191     pVec->pArray = NULL;
00192     return p;
00193 }

static float Vec_FltEntry ( Vec_Flt_t p,
int  i 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file vecFlt.h.

00276 {
00277     assert( i >= 0 && i < p->nSize );
00278     return p->pArray[i];
00279 }

static float Vec_FltEntryLast ( Vec_Flt_t p  )  [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 326 of file vecFlt.h.

00327 {
00328     return p->pArray[p->nSize-1];
00329 }

static void Vec_FltFill ( Vec_Flt_t p,
int  nSize,
float  Entry 
) [inline, static]

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 361 of file vecFlt.h.

00362 {
00363     int i;
00364     Vec_FltGrow( p, nSize );
00365     for ( i = 0; i < nSize; i++ )
00366         p->pArray[i] = Entry;
00367     p->nSize = nSize;
00368 }

static void Vec_FltFillExtra ( Vec_Flt_t p,
int  nSize,
float  Entry 
) [inline, static]

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 381 of file vecFlt.h.

00382 {
00383     int i;
00384     if ( p->nSize >= nSize )
00385         return;
00386     Vec_FltGrow( p, nSize );
00387     for ( i = p->nSize; i < nSize; i++ )
00388         p->pArray[i] = Entry;
00389     p->nSize = nSize;
00390 }

static int Vec_FltFind ( Vec_Flt_t p,
float  Entry 
) [inline, static]

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

Synopsis [Find entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 527 of file vecFlt.h.

00528 {
00529     int i;
00530     for ( i = 0; i < p->nSize; i++ )
00531         if ( p->pArray[i] == Entry )
00532             return i;
00533     return -1;
00534 }

static void Vec_FltFree ( Vec_Flt_t p  )  [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file vecFlt.h.

00207 {
00208     FREE( p->pArray );
00209     FREE( p );
00210 }

static void Vec_FltGrow ( Vec_Flt_t p,
int  nCapMin 
) [inline, static]

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 342 of file vecFlt.h.

00343 {
00344     if ( p->nCap >= nCapMin )
00345         return;
00346     p->pArray = REALLOC( float, p->pArray, nCapMin ); 
00347     p->nCap   = nCapMin;
00348 }

static float Vec_FltPop ( Vec_Flt_t p  )  [inline, static]

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 510 of file vecFlt.h.

00511 {
00512     assert( p->nSize > 0 );
00513     return p->pArray[--p->nSize];
00514 }

static void Vec_FltPush ( Vec_Flt_t p,
float  Entry 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 436 of file vecFlt.h.

00437 {
00438     if ( p->nSize == p->nCap )
00439     {
00440         if ( p->nCap < 16 )
00441             Vec_FltGrow( p, 16 );
00442         else
00443             Vec_FltGrow( p, 2 * p->nCap );
00444     }
00445     p->pArray[p->nSize++] = Entry;
00446 }

static void Vec_FltPushOrder ( Vec_Flt_t p,
float  Entry 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 459 of file vecFlt.h.

00460 {
00461     int i;
00462     if ( p->nSize == p->nCap )
00463     {
00464         if ( p->nCap < 16 )
00465             Vec_FltGrow( p, 16 );
00466         else
00467             Vec_FltGrow( p, 2 * p->nCap );
00468     }
00469     p->nSize++;
00470     for ( i = p->nSize-2; i >= 0; i-- )
00471         if ( p->pArray[i] > Entry )
00472             p->pArray[i+1] = p->pArray[i];
00473         else
00474             break;
00475     p->pArray[i+1] = Entry;
00476 }

static int Vec_FltPushUnique ( Vec_Flt_t p,
float  Entry 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file vecFlt.h.

00490 {
00491     int i;
00492     for ( i = 0; i < p->nSize; i++ )
00493         if ( p->pArray[i] == Entry )
00494             return 1;
00495     Vec_FltPush( p, Entry );
00496     return 0;
00497 }

static float* Vec_FltReleaseArray ( Vec_Flt_t p  )  [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file vecFlt.h.

00224 {
00225     float * pArray = p->pArray;
00226     p->nCap = 0;
00227     p->nSize = 0;
00228     p->pArray = NULL;
00229     return pArray;
00230 }

static int Vec_FltRemove ( Vec_Flt_t p,
float  Entry 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 547 of file vecFlt.h.

00548 {
00549     int i;
00550     for ( i = 0; i < p->nSize; i++ )
00551         if ( p->pArray[i] == Entry )
00552             break;
00553     if ( i == p->nSize )
00554         return 0;
00555     assert( i < p->nSize );
00556     for ( i++; i < p->nSize; i++ )
00557         p->pArray[i-1] = p->pArray[i];
00558     p->nSize--;
00559     return 1;
00560 }

static void Vec_FltShrink ( Vec_Flt_t p,
int  nSizeNew 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 403 of file vecFlt.h.

00404 {
00405     assert( p->nSize >= nSizeNew );
00406     p->nSize = nSizeNew;
00407 }

static int Vec_FltSize ( Vec_Flt_t p  )  [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 259 of file vecFlt.h.

00260 {
00261     return p->nSize;
00262 }

static void Vec_FltSort ( Vec_Flt_t p,
int  fReverse 
) [inline, static]

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

Synopsis [Sorting the entries by their value.]

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file vecFlt.h.

00616 {
00617     if ( fReverse ) 
00618         qsort( (void *)p->pArray, p->nSize, sizeof(float), 
00619                 (int (*)(const void *, const void *)) Vec_FltSortCompare2 );
00620     else
00621         qsort( (void *)p->pArray, p->nSize, sizeof(float), 
00622                 (int (*)(const void *, const void *)) Vec_FltSortCompare1 );
00623 }

static int Vec_FltSortCompare1 ( float *  pp1,
float *  pp2 
) [inline, static]

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

Synopsis [Comparison procedure for two floats.]

Description []

SideEffects []

SeeAlso []

Definition at line 573 of file vecFlt.h.

00574 {
00575     // for some reason commenting out lines (as shown) led to crashing of the release version
00576     if ( *pp1 < *pp2 )
00577         return -1;
00578     if ( *pp1 > *pp2 ) //
00579         return 1;
00580     return 0; //
00581 }

static int Vec_FltSortCompare2 ( float *  pp1,
float *  pp2 
) [inline, static]

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

Synopsis [Comparison procedure for two floats.]

Description []

SideEffects []

SeeAlso []

Definition at line 594 of file vecFlt.h.

00595 {
00596     // for some reason commenting out lines (as shown) led to crashing of the release version
00597     if ( *pp1 > *pp2 )
00598         return -1;
00599     if ( *pp1 < *pp2 ) //
00600         return 1;
00601     return 0; //
00602 }

static Vec_Flt_t* Vec_FltStart ( int  nSize  )  [inline, static]

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

Synopsis [Allocates a vector with the given size and cleans it.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file vecFlt.h.

00098 {
00099     Vec_Flt_t * p;
00100     p = Vec_FltAlloc( nSize );
00101     p->nSize = nSize;
00102     memset( p->pArray, 0, sizeof(float) * nSize );
00103     return p;
00104 }

static void Vec_FltWriteEntry ( Vec_Flt_t p,
int  i,
float  Entry 
) [inline, static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 292 of file vecFlt.h.

00293 {
00294     assert( i >= 0 && i < p->nSize );
00295     p->pArray[i] = Entry;
00296 }


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