From 0c6f196e2aed5138e2b5887a88fc92ad5a545118 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 19 Jun 2014 11:26:06 -0700 Subject: Experiments with MUX profiling. --- src/misc/vec/vecPtr.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/misc/vec/vecPtr.h') diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h index d0204ebb..a666f45f 100644 --- a/src/misc/vec/vecPtr.h +++ b/src/misc/vec/vecPtr.h @@ -883,6 +883,31 @@ static void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() ) p->pArray[k++] = p->pArray[i]; p->nSize = k; } +static void Vec_PtrUniqify2( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)(), void (*Vec_PtrObjFree)(), Vec_Int_t * vCounts ) +{ + int i, k; + if ( vCounts ) + Vec_IntFill( vCounts, 1, 1 ); + if ( p->nSize < 2 ) + return; + Vec_PtrSort( p, Vec_PtrSortCompare ); + for ( i = k = 1; i < p->nSize; i++ ) + if ( Vec_PtrSortCompare(p->pArray+i, p->pArray+k-1) != 0 ) + { + p->pArray[k++] = p->pArray[i]; + if ( vCounts ) + Vec_IntPush( vCounts, 1 ); + } + else + { + if ( Vec_PtrObjFree ) + Vec_PtrObjFree( p->pArray[i] ); + if ( vCounts ) + Vec_IntAddToEntry( vCounts, Vec_IntSize(vCounts)-1, 1 ); + } + p->nSize = k; + assert( vCounts == NULL || Vec_IntSize(vCounts) == Vec_PtrSize(p) ); +} -- cgit v1.2.3