21 #ifndef ABC__misc__vec__vecFlt_h
22 #define ABC__misc__vec__vecFlt_h
54 #define Vec_FltForEachEntry( vVec, Entry, i ) \
55 for ( i = 0; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
56 #define Vec_FltForEachEntryStart( vVec, Entry, i, Start ) \
57 for ( i = Start; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
58 #define Vec_FltForEachEntryStartStop( vVec, Entry, i, Start, Stop ) \
59 for ( i = Start; (i < Stop) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
60 #define Vec_FltForEachEntryReverse( vVec, pEntry, i ) \
61 for ( i = Vec_FltSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_FltEntry(vVec, i)), 1); i-- )
82 if ( nCap > 0 && nCap < 16 )
86 p->pArray = p->nCap?
ABC_ALLOC(
float, p->nCap ) : NULL;
106 memset( p->pArray, 0,
sizeof(
float) * nSize );
114 memset( p->pArray, 0xFF,
sizeof(
float) * nSize );
157 memcpy( p->pArray, pArray,
sizeof(
float) * nSize );
176 p->nSize = pVec->nSize;
177 p->nCap = pVec->nCap;
178 p->pArray = p->nCap?
ABC_ALLOC(
float, p->nCap ) : NULL;
179 memcpy( p->pArray, pVec->pArray,
sizeof(
float) * pVec->nSize );
198 p->nSize = pVec->nSize;
199 p->nCap = pVec->nCap;
200 p->pArray = pVec->pArray;
256 float * pArray = p->pArray;
328 return !p ? 0.0 : 1.0 *
sizeof(float) * p->nCap +
sizeof(
Vec_Flt_t);
344 assert( i >= 0 && i < p->nSize );
349 assert( i >= 0 && i < p->nSize );
350 return p->pArray + i;
366 assert( i >= 0 && i < p->nSize );
367 p->pArray[i] = Entry;
383 assert( i >= 0 && i < p->nSize );
384 p->pArray[i] += Addition;
417 return p->pArray[p->nSize-1];
433 if ( p->nCap >= nCapMin )
435 p->pArray =
ABC_REALLOC(
float, p->pArray, nCapMin );
454 for ( i = 0; i < nSize; i++ )
455 p->pArray[i] = Entry;
473 if ( nSize <= p->nSize )
475 if ( nSize > 2 * p->nCap )
477 else if ( nSize > p->nCap )
479 for ( i = p->nSize; i < nSize; i++ )
497 assert( p->nSize >= nSizeNew );
530 if ( p->nSize == p->nCap )
537 p->pArray[p->nSize++] = Entry;
554 if ( p->nSize == p->nCap )
562 for ( i = p->nSize-2; i >= 0; i-- )
563 if ( p->pArray[i] > Entry )
564 p->pArray[i+1] = p->pArray[i];
567 p->pArray[i+1] = Entry;
584 for ( i = 0; i < p->nSize; i++ )
585 if ( p->pArray[i] == Entry )
605 return p->pArray[--p->nSize];
622 for ( i = 0; i < p->nSize; i++ )
623 if ( p->pArray[i] == Entry )
642 for ( i = 0; i < p->nSize; i++ )
643 if ( p->pArray[i] == Entry )
648 for ( i++; i < p->nSize; i++ )
649 p->pArray[i-1] = p->pArray[i];
672 for ( i = 1; i < p->nSize; i++ )
673 if ( Best < p->pArray[i] )
684 for ( i = 1; i < p->nSize; i++ )
685 if ( Best > p->pArray[i] )
704 if ( p1->nSize != p2->nSize )
706 for ( i = 0; i < p1->nSize; i++ )
707 if ( p1->pArray[i] != p2->pArray[i] )
726 printf(
"Vector has %d entries: {",
Vec_FltSize(vVec) );
728 printf(
" %f", Entry );
788 qsort( (
void *)p->pArray, p->nSize,
sizeof(
float),
791 qsort( (
void *)p->pArray, p->nSize,
sizeof(
float),
static Vec_Flt_t * Vec_FltAllocArrayCopy(float *pArray, int nSize)
static double Vec_FltMemory(Vec_Flt_t *p)
#define Vec_FltForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static void Vec_FltFillExtra(Vec_Flt_t *p, int nSize, float Fill)
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
static Vec_Flt_t * Vec_FltDup(Vec_Flt_t *pVec)
static float * Vec_FltEntryP(Vec_Flt_t *p, int i)
static void Vec_FltShrink(Vec_Flt_t *p, int nSizeNew)
static int Vec_FltRemove(Vec_Flt_t *p, float Entry)
static float Vec_FltFindMax(Vec_Flt_t *p)
static int Vec_FltCap(Vec_Flt_t *p)
#define ABC_REALLOC(type, obj, num)
static void Vec_FltFree(Vec_Flt_t *p)
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define ABC_ALLOC(type, num)
static float * Vec_FltArray(Vec_Flt_t *p)
static void Vec_FltFill(Vec_Flt_t *p, int nSize, float Entry)
static void Vec_FltFreeP(Vec_Flt_t **p)
static void Vec_FltPush(Vec_Flt_t *p, float Entry)
static int Vec_FltEqual(Vec_Flt_t *p1, Vec_Flt_t *p2)
static float Vec_FltEntryLast(Vec_Flt_t *p)
static Vec_Flt_t * Vec_FltStart(int nSize)
static void Vec_FltClear(Vec_Flt_t *p)
static void Vec_FltPrint(Vec_Flt_t *vVec)
static float Vec_FltPop(Vec_Flt_t *p)
static void Vec_FltUpdateEntry(Vec_Flt_t *p, int i, float Value)
static int Vec_FltPushUnique(Vec_Flt_t *p, float Entry)
static void Vec_FltGrow(Vec_Flt_t *p, int nCapMin)
static Vec_Flt_t * Vec_FltAllocArray(float *pArray, int nSize)
static void Vec_FltPushOrder(Vec_Flt_t *p, float Entry)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define ABC_NAMESPACE_HEADER_END
static Vec_Flt_t * Vec_FltStartFull(int nSize)
static void Vec_FltAddToEntry(Vec_Flt_t *p, int i, float Addition)
static float ** Vec_FltArrayP(Vec_Flt_t *p)
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
static int Vec_FltFind(Vec_Flt_t *p, float Entry)
static float * Vec_FltReleaseArray(Vec_Flt_t *p)
static float Vec_FltEntry(Vec_Flt_t *p, int i)
static float Vec_FltFindMin(Vec_Flt_t *p)
static Vec_Flt_t * Vec_FltDupArray(Vec_Flt_t *pVec)
static int Vec_FltSize(Vec_Flt_t *p)
static void Vec_FltSort(Vec_Flt_t *p, int fReverse)
static int Vec_FltSortCompare2(float *pp1, float *pp2)
static int Vec_FltSortCompare1(float *pp1, float *pp2)