diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-08-26 14:30:42 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-08-26 14:30:42 -0700 |
commit | cb439f2ecf000ebaab4447de120a95480b231ef5 (patch) | |
tree | 68a0b3a5df89ebaf5c22fc93cd1bcd33bfb1f785 /src/misc | |
parent | 41d18ca05113b33508cb67d10c2ec1fecfd4d4b2 (diff) | |
download | abc-cb439f2ecf000ebaab4447de120a95480b231ef5.tar.gz abc-cb439f2ecf000ebaab4447de120a95480b231ef5.tar.bz2 abc-cb439f2ecf000ebaab4447de120a95480b231ef5.zip |
Bug fix in Vec_IntInsert() and a couple of new APIs.
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/vec/vecInt.h | 2 | ||||
-rw-r--r-- | src/misc/vec/vecPtr.h | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 785b0aef..8ef1c364 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -1013,7 +1013,7 @@ static inline void Vec_IntDrop( Vec_Int_t * p, int i ) static inline void Vec_IntInsert( Vec_Int_t * p, int iHere, int Entry ) { int i; - assert( iHere >= 0 && iHere < p->nSize ); + assert( iHere >= 0 && iHere <= p->nSize ); Vec_IntPush( p, 0 ); for ( i = p->nSize - 1; i > iHere; i-- ) p->pArray[i] = p->pArray[i-1]; diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h index 5fa40112..b700d221 100644 --- a/src/misc/vec/vecPtr.h +++ b/src/misc/vec/vecPtr.h @@ -64,6 +64,8 @@ struct Vec_Ptr_t_ for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i-- ) #define Vec_PtrForEachEntryTwo( Type1, vVec1, Type2, vVec2, pEntry1, pEntry2, i ) \ for ( i = 0; (i < Vec_PtrSize(vVec1)) && (((pEntry1) = (Type1)Vec_PtrEntry(vVec1, i)), 1) && (((pEntry2) = (Type2)Vec_PtrEntry(vVec2, i)), 1); i++ ) +#define Vec_PtrForEachEntryDouble( Type1, Type2, vVec, Entry1, Entry2, i ) \ + for ( i = 0; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = (Type1)Vec_PtrEntry(vVec, i)), 1) && (((Entry2) = (Type2)Vec_PtrEntry(vVec, i+1)), 1); i += 2 ) //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -464,6 +466,14 @@ static inline void Vec_PtrFill( Vec_Ptr_t * p, int nSize, void * Entry ) p->pArray[i] = Entry; p->nSize = nSize; } +static inline void Vec_PtrFillTwo( Vec_Ptr_t * p, int nSize, void * EntryEven, void * EntryOdd ) +{ + int i; + Vec_PtrGrow( p, nSize ); + for ( i = 0; i < nSize; i++ ) + p->pArray[i] = (i & 1) ? EntryOdd : EntryEven; + p->nSize = nSize; +} /**Function************************************************************* @@ -624,6 +634,11 @@ static inline void Vec_PtrPush( Vec_Ptr_t * p, void * Entry ) } p->pArray[p->nSize++] = Entry; } +static inline void Vec_PtrPushTwo( Vec_Ptr_t * p, void * Entry1, void * Entry2 ) +{ + Vec_PtrPush( p, Entry1 ); + Vec_PtrPush( p, Entry2 ); +} /**Function************************************************************* |