summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2009-03-10 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2009-03-10 08:01:00 -0700
commit32314347bae6ddcd841a268e797ec4da45726abb (patch)
treee2e5fd1711f04a06d0da2b8003bc02cb9a5dd446 /src/misc/vec
parentc03f9b516bed2c06ec2bfc78617eba5fc9a11c32 (diff)
downloadabc-32314347bae6ddcd841a268e797ec4da45726abb.tar.gz
abc-32314347bae6ddcd841a268e797ec4da45726abb.tar.bz2
abc-32314347bae6ddcd841a268e797ec4da45726abb.zip
Version abc90310
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecFlt.h2
-rw-r--r--src/misc/vec/vecInt.h29
-rw-r--r--src/misc/vec/vecPtr.h30
-rw-r--r--src/misc/vec/vecStr.h7
4 files changed, 56 insertions, 12 deletions
diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h
index 93402cf2..8f0ea42d 100644
--- a/src/misc/vec/vecFlt.h
+++ b/src/misc/vec/vecFlt.h
@@ -383,6 +383,8 @@ static inline void Vec_FltFillExtra( Vec_Flt_t * p, int nSize, float Entry )
int i;
if ( p->nSize >= nSize )
return;
+ if ( nSize < 2 * p->nSize )
+ nSize = 2 * p->nSize;
Vec_FltGrow( p, nSize );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Entry;
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index 0f7a41ab..c3c92f09 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -409,10 +409,9 @@ static inline void Vec_IntFillExtra( Vec_Int_t * p, int nSize, int Fill )
int i;
if ( p->nSize >= nSize )
return;
- if ( 2 * p->nSize > nSize )
- Vec_IntGrow( p, 2 * nSize );
- else
- Vec_IntGrow( p, nSize );
+ if ( nSize < 2 * p->nSize )
+ nSize = 2 * p->nSize;
+ Vec_IntGrow( p, nSize );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Fill;
p->nSize = nSize;
@@ -743,6 +742,28 @@ static inline int Vec_IntFindMin( Vec_Int_t * p )
/**Function*************************************************************
+ Synopsis [Reverses the order of entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_IntReverseOrder( Vec_Int_t * p )
+{
+ int i, Temp;
+ for ( i = 0; i < p->nSize/2; i++ )
+ {
+ Temp = p->pArray[i];
+ p->pArray[i] = p->pArray[p->nSize-1-i];
+ p->pArray[p->nSize-1-i] = Temp;
+ }
+}
+
+/**Function*************************************************************
+
Synopsis [Comparison procedure for two integers.]
Description []
diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h
index 4d09acb7..6fc5109b 100644
--- a/src/misc/vec/vecPtr.h
+++ b/src/misc/vec/vecPtr.h
@@ -388,10 +388,9 @@ static inline void Vec_PtrFillExtra( Vec_Ptr_t * p, int nSize, void * Entry )
if ( p->nSize >= nSize )
return;
assert( p->nSize < nSize );
- if ( 2 * p->nSize > nSize )
- Vec_PtrGrow( p, 2 * nSize );
- else
- Vec_PtrGrow( p, nSize );
+ if ( nSize < 2 * p->nSize )
+ nSize = 2 * p->nSize;
+ Vec_PtrGrow( p, nSize );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Entry;
p->nSize = nSize;
@@ -616,6 +615,29 @@ static inline void Vec_PtrReorder( Vec_Ptr_t * p, int nItems )
/**Function*************************************************************
+ Synopsis [Reverses the order of entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_PtrReverseOrder( Vec_Ptr_t * p )
+{
+ void * Temp;
+ int i;
+ for ( i = 0; i < p->nSize/2; i++ )
+ {
+ Temp = p->pArray[i];
+ p->pArray[i] = p->pArray[p->nSize-1-i];
+ p->pArray[p->nSize-1-i] = Temp;
+ }
+}
+
+/**Function*************************************************************
+
Synopsis [Sorting the entries by their integer value.]
Description []
diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h
index dc0b2bad..c77a3a17 100644
--- a/src/misc/vec/vecStr.h
+++ b/src/misc/vec/vecStr.h
@@ -361,10 +361,9 @@ static inline void Vec_StrFillExtra( Vec_Str_t * p, int nSize, char Fill )
int i;
if ( p->nSize >= nSize )
return;
- if ( 2 * p->nSize > nSize )
- Vec_StrGrow( p, 2 * nSize );
- else
- Vec_StrGrow( p, nSize );
+ if ( nSize < 2 * p->nSize )
+ nSize = 2 * p->nSize;
+ Vec_StrGrow( p, nSize );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Fill;
p->nSize = nSize;