//******************************************** // PCSA.h // ------------------------------------------- // The header file of the general purpose PCSA // module // // Author: Leiwen Deng // Date: 10/15/2005 //******************************************** #ifndef PCSA_H #define PCSA_H #include #include #include #include #include #include //#define WINXP #ifndef WINXP #include "mangler.h" #else typedef unsigned int uint32; typedef unsigned short u_short; #endif // The hash function type typedef uint32 (* HASH_FUNC)( const void * key ); //******************************************** // PCSA class // ------------------------------------------- // The PCSA counting unit. // Each unit can perform the probabilistic // counting for a multiset by using the PCSA // (Probabilistic Counting with Stochastic // Average) algorithm. // Each unit includes: // an integer specifies the "m_bit" parameter // an integer specifies the number of bitmaps // a number of bitmaps // a hash function //******************************************** class PCSA { int nmap_bit; // the integer specifies the "m_bit" parameter int nmap; // the integer specifies the number of bitmaps, = 2 ** uint32 * bitmap; // the pointer to the table of bitmaps HASH_FUNC hash; // the pointer to the hash function // Initialize the table of bitmaps char InitializeBitmap( void ); // Initialize all bitmaps to be empty char ResetBitmap( void ); // Update the bitmap table by inputting a hashed value char UpdateBitmap( uint32 hash_value ); // Calculates a 32-bit mask code of an input value uint32 Rou( uint32 value ) const; public: // Input an element of the multiset to the counting system char InputValue( const void * value ); // Calculate the PCSA cardinality of the inputted multiset int GetCardinality( void ) const; // The constructor PCSA( int nmap_bit_in, HASH_FUNC hash_in ); // The destructor ~PCSA( void ); }; // A portable pseudorandom number generator double d_uniform_01( int * seed ); // The compact version of above d_uniform_01 double d_uniform_01( void ); // A hash function used for mangling the 32-bit IPv4 address uint32 IP_Hash( const void * IP ); // A fake hash function for 32-bit integers uint32 No_Hash( const void * key ); #endif