Bug fix in Vec_IntInsert() and a couple of new APIs.

This commit is contained in:
Alan Mishchenko
2015-08-26 14:30:42 -07:00
parent 41d18ca051
commit cb439f2ecf
3 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -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];
+15
View File
@@ -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*************************************************************