#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | Vec_Int_t_ |
Defines | |
#define | Vec_IntForEachEntry(vVec, Entry, i) for ( i = 0; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) |
#define | Vec_IntForEachEntryStart(vVec, Entry, i, Start) for ( i = Start; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) |
#define | Vec_IntForEachEntryStartStop(vVec, Entry, i, Start, Stop) for ( i = Start; (i < Stop) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) |
#define | Vec_IntForEachEntryReverse(vVec, pEntry, i) for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_IntEntry(vVec, i)), 1); i-- ) |
Typedefs | |
typedef struct Vec_Int_t_ | Vec_Int_t |
Functions | |
static Vec_Int_t * | Vec_IntAlloc (int nCap) |
static Vec_Int_t * | Vec_IntStart (int nSize) |
static Vec_Int_t * | Vec_IntStartNatural (int nSize) |
static Vec_Int_t * | Vec_IntAllocArray (int *pArray, int nSize) |
static Vec_Int_t * | Vec_IntAllocArrayCopy (int *pArray, int nSize) |
static Vec_Int_t * | Vec_IntDup (Vec_Int_t *pVec) |
static Vec_Int_t * | Vec_IntDupArray (Vec_Int_t *pVec) |
static void | Vec_IntFree (Vec_Int_t *p) |
static int * | Vec_IntReleaseArray (Vec_Int_t *p) |
static int * | Vec_IntArray (Vec_Int_t *p) |
static int | Vec_IntSize (Vec_Int_t *p) |
static int | Vec_IntEntry (Vec_Int_t *p, int i) |
static void | Vec_IntWriteEntry (Vec_Int_t *p, int i, int Entry) |
static void | Vec_IntAddToEntry (Vec_Int_t *p, int i, int Addition) |
static int | Vec_IntEntryLast (Vec_Int_t *p) |
static void | Vec_IntGrow (Vec_Int_t *p, int nCapMin) |
static void | Vec_IntFill (Vec_Int_t *p, int nSize, int Entry) |
static void | Vec_IntFillExtra (Vec_Int_t *p, int nSize, int Entry) |
static void | Vec_IntShrink (Vec_Int_t *p, int nSizeNew) |
static void | Vec_IntClear (Vec_Int_t *p) |
static void | Vec_IntPush (Vec_Int_t *p, int Entry) |
static void | Vec_IntPushFirst (Vec_Int_t *p, int Entry) |
static void | Vec_IntPushOrder (Vec_Int_t *p, int Entry) |
static int | Vec_IntPushUniqueOrder (Vec_Int_t *p, int Entry) |
static int | Vec_IntPushUnique (Vec_Int_t *p, int Entry) |
static unsigned * | Vec_IntFetch (Vec_Int_t *p, int nWords) |
static int | Vec_IntPop (Vec_Int_t *p) |
static int | Vec_IntFind (Vec_Int_t *p, int Entry) |
static int | Vec_IntRemove (Vec_Int_t *p, int Entry) |
static int | Vec_IntSortCompare1 (int *pp1, int *pp2) |
static int | Vec_IntSortCompare2 (int *pp1, int *pp2) |
static void | Vec_IntSort (Vec_Int_t *p, int fReverse) |
static int | Vec_IntSortCompareUnsigned (unsigned *pp1, unsigned *pp2) |
static void | Vec_IntSortUnsigned (Vec_Int_t *p) |
static int | Vec_IntTwoCountCommon (Vec_Int_t *vArr1, Vec_Int_t *vArr2) |
static Vec_Int_t * | Vec_IntTwoMerge (Vec_Int_t *vArr1, Vec_Int_t *vArr2) |
#define Vec_IntForEachEntry | ( | vVec, | |||
Entry, | |||||
i | ) | for ( i = 0; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) |
#define Vec_IntForEachEntryReverse | ( | vVec, | |||
pEntry, | |||||
i | ) | for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_IntEntry(vVec, i)), 1); i-- ) |
#define Vec_IntForEachEntryStart | ( | vVec, | |||
Entry, | |||||
i, | |||||
Start | ) | for ( i = Start; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) |
#define Vec_IntForEachEntryStartStop | ( | vVec, | |||
Entry, | |||||
i, | |||||
Start, | |||||
Stop | ) | for ( i = Start; (i < Stop) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) |
typedef struct Vec_Int_t_ Vec_Int_t |
CFile****************************************************************
FileName [vecInt.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resizable arrays.]
Synopsis [Resizable arrays of integers.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
] INCLUDES /// PARAMETERS /// BASIC TYPES ///
static void Vec_IntAddToEntry | ( | Vec_Int_t * | p, | |
int | i, | |||
int | Addition | |||
) | [inline, static] |
static Vec_Int_t* Vec_IntAlloc | ( | int | nCap | ) | [inline, static] |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
static Vec_Int_t* Vec_IntAllocArray | ( | int * | pArray, | |
int | nSize | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Creates the vector from an integer array of the given size.]
Description []
SideEffects []
SeeAlso []
static Vec_Int_t* Vec_IntAllocArrayCopy | ( | int * | pArray, | |
int | nSize | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Creates the vector from an integer array of the given size.]
Description []
SideEffects []
SeeAlso []
static int* Vec_IntArray | ( | Vec_Int_t * | p | ) | [inline, static] |
static void Vec_IntClear | ( | Vec_Int_t * | p | ) | [inline, static] |
Function*************************************************************
Synopsis [Duplicates the integer array.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis [Transfers the array into another vector.]
Description []
SideEffects []
SeeAlso []
static int Vec_IntEntry | ( | Vec_Int_t * | p, | |
int | i | |||
) | [inline, static] |
static int Vec_IntEntryLast | ( | Vec_Int_t * | p | ) | [inline, static] |
static unsigned* Vec_IntFetch | ( | Vec_Int_t * | p, | |
int | nWords | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Returns the pointer to the next nWords entries in the vector.]
Description []
SideEffects []
SeeAlso []
static void Vec_IntFill | ( | Vec_Int_t * | p, | |
int | nSize, | |||
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Fills the vector with given number of entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 385 of file vecInt.h.
00386 { 00387 int i; 00388 Vec_IntGrow( p, nSize ); 00389 for ( i = 0; i < nSize; i++ ) 00390 p->pArray[i] = Entry; 00391 p->nSize = nSize; 00392 }
static void Vec_IntFillExtra | ( | Vec_Int_t * | p, | |
int | nSize, | |||
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Fills the vector with given number of entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 405 of file vecInt.h.
00406 { 00407 int i; 00408 if ( p->nSize >= nSize ) 00409 return; 00410 Vec_IntGrow( p, nSize ); 00411 for ( i = p->nSize; i < nSize; i++ ) 00412 p->pArray[i] = Entry; 00413 p->nSize = nSize; 00414 }
static int Vec_IntFind | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Find entry.]
Description []
SideEffects []
SeeAlso []
static void Vec_IntFree | ( | Vec_Int_t * | p | ) | [inline, static] |
static void Vec_IntGrow | ( | Vec_Int_t * | p, | |
int | nCapMin | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Resizes the vector to the given capacity.]
Description []
SideEffects []
SeeAlso []
static int Vec_IntPop | ( | Vec_Int_t * | p | ) | [inline, static] |
static void Vec_IntPush | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 460 of file vecInt.h.
00461 { 00462 if ( p->nSize == p->nCap ) 00463 { 00464 if ( p->nCap < 16 ) 00465 Vec_IntGrow( p, 16 ); 00466 else 00467 Vec_IntGrow( p, 2 * p->nCap ); 00468 } 00469 p->pArray[p->nSize++] = Entry; 00470 }
static void Vec_IntPushFirst | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 483 of file vecInt.h.
00484 { 00485 int i; 00486 if ( p->nSize == p->nCap ) 00487 { 00488 if ( p->nCap < 16 ) 00489 Vec_IntGrow( p, 16 ); 00490 else 00491 Vec_IntGrow( p, 2 * p->nCap ); 00492 } 00493 p->nSize++; 00494 for ( i = p->nSize - 1; i >= 1; i-- ) 00495 p->pArray[i] = p->pArray[i-1]; 00496 p->pArray[0] = Entry; 00497 }
static void Vec_IntPushOrder | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Inserts the entry while preserving the increasing order.]
Description []
SideEffects []
SeeAlso []
Definition at line 510 of file vecInt.h.
00511 { 00512 int i; 00513 if ( p->nSize == p->nCap ) 00514 { 00515 if ( p->nCap < 16 ) 00516 Vec_IntGrow( p, 16 ); 00517 else 00518 Vec_IntGrow( p, 2 * p->nCap ); 00519 } 00520 p->nSize++; 00521 for ( i = p->nSize-2; i >= 0; i-- ) 00522 if ( p->pArray[i] > Entry ) 00523 p->pArray[i+1] = p->pArray[i]; 00524 else 00525 break; 00526 p->pArray[i+1] = Entry; 00527 }
static int Vec_IntPushUnique | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 561 of file vecInt.h.
00562 { 00563 int i; 00564 for ( i = 0; i < p->nSize; i++ ) 00565 if ( p->pArray[i] == Entry ) 00566 return 1; 00567 Vec_IntPush( p, Entry ); 00568 return 0; 00569 }
static int Vec_IntPushUniqueOrder | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Inserts the entry while preserving the increasing order.]
Description []
SideEffects []
SeeAlso []
Definition at line 540 of file vecInt.h.
00541 { 00542 int i; 00543 for ( i = 0; i < p->nSize; i++ ) 00544 if ( p->pArray[i] == Entry ) 00545 return 1; 00546 Vec_IntPushOrder( p, Entry ); 00547 return 0; 00548 }
static int* Vec_IntReleaseArray | ( | Vec_Int_t * | p | ) | [inline, static] |
static int Vec_IntRemove | ( | Vec_Int_t * | p, | |
int | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
static void Vec_IntShrink | ( | Vec_Int_t * | p, | |
int | nSizeNew | |||
) | [inline, static] |
static int Vec_IntSize | ( | Vec_Int_t * | p | ) | [inline, static] |
static void Vec_IntSort | ( | Vec_Int_t * | p, | |
int | fReverse | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Sorting the entries by their integer value.]
Description []
SideEffects []
SeeAlso []
Definition at line 712 of file vecInt.h.
00713 { 00714 if ( fReverse ) 00715 qsort( (void *)p->pArray, p->nSize, sizeof(int), 00716 (int (*)(const void *, const void *)) Vec_IntSortCompare2 ); 00717 else 00718 qsort( (void *)p->pArray, p->nSize, sizeof(int), 00719 (int (*)(const void *, const void *)) Vec_IntSortCompare1 ); 00720 }
static int Vec_IntSortCompare1 | ( | int * | pp1, | |
int * | pp2 | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Comparison procedure for two integers.]
Description []
SideEffects []
SeeAlso []
static int Vec_IntSortCompare2 | ( | int * | pp1, | |
int * | pp2 | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Comparison procedure for two integers.]
Description []
SideEffects []
SeeAlso []
static int Vec_IntSortCompareUnsigned | ( | unsigned * | pp1, | |
unsigned * | pp2 | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Comparison procedure for two integers.]
Description []
SideEffects []
SeeAlso []
static void Vec_IntSortUnsigned | ( | Vec_Int_t * | p | ) | [inline, static] |
Function*************************************************************
Synopsis [Sorting the entries by their integer value.]
Description []
SideEffects []
SeeAlso []
Definition at line 754 of file vecInt.h.
00755 { 00756 qsort( (void *)p->pArray, p->nSize, sizeof(int), 00757 (int (*)(const void *, const void *)) Vec_IntSortCompareUnsigned ); 00758 }
static Vec_Int_t* Vec_IntStart | ( | int | nSize | ) | [inline, static] |
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 97 of file vecInt.h.
00098 { 00099 Vec_Int_t * p; 00100 p = Vec_IntAlloc( nSize ); 00101 p->nSize = nSize; 00102 memset( p->pArray, 0, sizeof(int) * nSize ); 00103 return p; 00104 }
static Vec_Int_t* Vec_IntStartNatural | ( | int | nSize | ) | [inline, static] |
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 117 of file vecInt.h.
00118 { 00119 Vec_Int_t * p; 00120 int i; 00121 p = Vec_IntAlloc( nSize ); 00122 p->nSize = nSize; 00123 for ( i = 0; i < nSize; i++ ) 00124 p->pArray[i] = i; 00125 return p; 00126 }
Function*************************************************************
Synopsis [Returns the number of common entries.]
Description [Assumes that the vectors are sorted in the increasing order.]
SideEffects []
SeeAlso []
Definition at line 771 of file vecInt.h.
00772 { 00773 int * pBeg1 = vArr1->pArray; 00774 int * pBeg2 = vArr2->pArray; 00775 int * pEnd1 = vArr1->pArray + vArr1->nSize; 00776 int * pEnd2 = vArr2->pArray + vArr2->nSize; 00777 int Counter = 0; 00778 while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 ) 00779 { 00780 if ( *pBeg1 == *pBeg2 ) 00781 pBeg1++, pBeg2++, Counter++; 00782 else if ( *pBeg1 < *pBeg2 ) 00783 pBeg1++; 00784 else 00785 pBeg2++; 00786 } 00787 return Counter; 00788 }
Function*************************************************************
Synopsis [Returns the result of merging the two vectors.]
Description [Assumes that the vectors are sorted in the increasing order.]
SideEffects []
SeeAlso []
Definition at line 801 of file vecInt.h.
00802 { 00803 Vec_Int_t * vArr = Vec_IntAlloc( vArr1->nSize + vArr2->nSize ); 00804 int * pBeg = vArr->pArray; 00805 int * pBeg1 = vArr1->pArray; 00806 int * pBeg2 = vArr2->pArray; 00807 int * pEnd1 = vArr1->pArray + vArr1->nSize; 00808 int * pEnd2 = vArr2->pArray + vArr2->nSize; 00809 while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 ) 00810 { 00811 if ( *pBeg1 == *pBeg2 ) 00812 *pBeg++ = *pBeg1++, pBeg2++; 00813 else if ( *pBeg1 < *pBeg2 ) 00814 *pBeg++ = *pBeg1++; 00815 else 00816 *pBeg++ = *pBeg2++; 00817 } 00818 while ( pBeg1 < pEnd1 ) 00819 *pBeg++ = *pBeg1++; 00820 while ( pBeg2 < pEnd2 ) 00821 *pBeg++ = *pBeg2++; 00822 vArr->nSize = pBeg - vArr->pArray; 00823 assert( vArr->nSize <= vArr->nCap ); 00824 assert( vArr->nSize >= vArr1->nSize ); 00825 assert( vArr->nSize >= vArr2->nSize ); 00826 return vArr; 00827 }
static void Vec_IntWriteEntry | ( | Vec_Int_t * | p, | |
int | i, | |||
int | Entry | |||
) | [inline, static] |