diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2006-11-02 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2006-11-02 08:01:00 -0800 |
commit | faf1265bb82f934cc14b6106ccce89e37203efbd (patch) | |
tree | f6d69ce4adca5d7e1fdccd3e9848220d6744405d /src/misc/vec | |
parent | 73bb7932f7edad95086d67a795444537c438309e (diff) | |
download | abc-faf1265bb82f934cc14b6106ccce89e37203efbd.tar.gz abc-faf1265bb82f934cc14b6106ccce89e37203efbd.tar.bz2 abc-faf1265bb82f934cc14b6106ccce89e37203efbd.zip |
Version abc61102
Diffstat (limited to 'src/misc/vec')
-rw-r--r-- | src/misc/vec/vecPtr.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h index 07ac0f17..38513a93 100644 --- a/src/misc/vec/vecPtr.h +++ b/src/misc/vec/vecPtr.h @@ -574,8 +574,34 @@ static inline void Vec_PtrReorder( Vec_Ptr_t * p, int nItems ) ***********************************************************************/ static inline void Vec_PtrSort( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() ) { + if ( p->nSize < 2 ) + return; + qsort( (void *)p->pArray, p->nSize, sizeof(void *), + (int (*)(const void *, const void *)) Vec_PtrSortCompare ); +} + +/**Function************************************************************* + + Synopsis [Sorting the entries by their integer value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() ) +{ + int i, k; + if ( p->nSize < 2 ) + return; qsort( (void *)p->pArray, p->nSize, sizeof(void *), (int (*)(const void *, const void *)) Vec_PtrSortCompare ); + for ( i = k = 1; i < p->nSize; i++ ) + if ( p->pArray[i] != p->pArray[i-1] ) + p->pArray[k++] = p->pArray[i]; + p->nSize = k; } #endif |