diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2006-08-04 08:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2006-08-04 08:01:00 -0700 |
commit | 6b44b18e69f4e26249140e10c459615a77b32fc5 (patch) | |
tree | 37fcec85b6fe6c5b526054a20cf31648a3f7c51b /src/temp/vec | |
parent | 103fa22e9ce6ecc0f10fee5dac29726a153b1774 (diff) | |
download | abc-6b44b18e69f4e26249140e10c459615a77b32fc5.tar.gz abc-6b44b18e69f4e26249140e10c459615a77b32fc5.tar.bz2 abc-6b44b18e69f4e26249140e10c459615a77b32fc5.zip |
Version abc60804
Diffstat (limited to 'src/temp/vec')
-rw-r--r-- | src/temp/vec/vecInt.h | 44 | ||||
-rw-r--r-- | src/temp/vec/vecPtr.h | 30 |
2 files changed, 52 insertions, 22 deletions
diff --git a/src/temp/vec/vecInt.h b/src/temp/vec/vecInt.h index 9db30af7..4a97fc91 100644 --- a/src/temp/vec/vecInt.h +++ b/src/temp/vec/vecInt.h @@ -289,23 +289,6 @@ static inline int Vec_IntEntry( Vec_Int_t * p, int i ) SeeAlso [] ***********************************************************************/ -static inline int * Vec_IntEntryP( Vec_Int_t * p, int i ) -{ - assert( i >= 0 && i < p->nSize ); - return p->pArray + i; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ static inline void Vec_IntWriteEntry( Vec_Int_t * p, int i, int Entry ) { assert( i >= 0 && i < p->nSize ); @@ -402,10 +385,7 @@ static inline void Vec_IntFillExtra( Vec_Int_t * p, int nSize, int Entry ) int i; if ( p->nSize >= nSize ) return; - if ( p->nSize < 2 * nSize ) - Vec_IntGrow( p, 2 * nSize ); - else - Vec_IntGrow( p, p->nSize ); + Vec_IntGrow( p, nSize ); for ( i = p->nSize; i < nSize; i++ ) p->pArray[i] = Entry; p->nSize = nSize; @@ -603,6 +583,28 @@ static inline int Vec_IntPushUnique( Vec_Int_t * p, int Entry ) /**Function************************************************************* + Synopsis [Returns the pointer to the next nWords entries in the vector.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline unsigned * Vec_IntFetch( Vec_Int_t * p, int nWords ) +{ + p->nSize += nWords; + if ( p->nSize > p->nCap ) + { +// Vec_IntGrow( p, 2 * p->nSize ); + return NULL; + } + return ((unsigned *)p->pArray) + p->nSize - nWords; +} + +/**Function************************************************************* + Synopsis [Returns the last entry and removes it from the list.] Description [] diff --git a/src/temp/vec/vecPtr.h b/src/temp/vec/vecPtr.h index 96975ff0..07ac0f17 100644 --- a/src/temp/vec/vecPtr.h +++ b/src/temp/vec/vecPtr.h @@ -293,6 +293,23 @@ static inline void * Vec_PtrEntry( Vec_Ptr_t * p, int i ) SeeAlso [] ***********************************************************************/ +static inline void ** Vec_PtrEntryP( Vec_Ptr_t * p, int i ) +{ + assert( i >= 0 && i < p->nSize ); + return p->pArray + i; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ static inline void Vec_PtrWriteEntry( Vec_Ptr_t * p, int i, void * Entry ) { assert( i >= 0 && i < p->nSize ); @@ -371,7 +388,10 @@ static inline void Vec_PtrFillExtra( Vec_Ptr_t * p, int nSize, void * Entry ) int i; if ( p->nSize >= nSize ) return; - Vec_PtrGrow( p, nSize ); + if ( p->nSize < 2 * nSize ) + Vec_PtrGrow( p, 2 * nSize ); + else + Vec_PtrGrow( p, p->nSize ); for ( i = p->nSize; i < nSize; i++ ) p->pArray[i] = Entry; p->nSize = nSize; @@ -505,10 +525,18 @@ static inline int Vec_PtrFind( Vec_Ptr_t * p, void * Entry ) static inline void Vec_PtrRemove( Vec_Ptr_t * p, void * Entry ) { int i; + // delete assuming that it is closer to the end + for ( i = p->nSize - 1; i >= 0; i-- ) + if ( p->pArray[i] == Entry ) + break; + assert( i >= 0 ); +/* + // delete assuming that it is closer to the beginning for ( i = 0; i < p->nSize; i++ ) if ( p->pArray[i] == Entry ) break; assert( i < p->nSize ); +*/ for ( i++; i < p->nSize; i++ ) p->pArray[i-1] = p->pArray[i]; p->nSize--; |