#ifndef _HEAPSTATS_H_
#define _HEAPSTATS_H_
#include "config.h"
class heapStats {
public:
heapStats(void)
: U(0), A(0)
#if HEAP_STATS
, Umax(0), Amax(0)
#endif
{
}
inline const heapStats & operator=(const heapStats & p);
inline void incStats(int updateU, int updateA);
inline void incUStats(void);
inline void decStats(int updateU, int updateA);
inline void decUStats(void);
inline void decUStats(int &Uout, int &Aout);
inline void getStats(int &Uout, int &Aout);
#if HEAP_STATS
inline int getUmax(void);
inline int getAmax(void);
#endif
private:
int U;
int A;
#if HEAP_STATS
int Umax;
int Amax;
#endif
};
inline void
heapStats::incStats(int updateU, int updateA)
{
assert(updateU >= 0);
assert(updateA >= 0);
assert(U <= A);
assert(U >= 0);
assert(A >= 0);
U += updateU;
A += updateA;
#if HEAP_STATS
Amax = MAX(Amax, A);
Umax = MAX(Umax, U);
#endif
assert(U <= A);
assert(U >= 0);
assert(A >= 0);
}
inline void
heapStats::incUStats(void)
{
assert(U < A);
assert(U >= 0);
assert(A >= 0);
U++;
#if HEAP_STATS
Umax = MAX(Umax, U);
#endif
assert(U >= 0);
assert(A >= 0);
}
inline void
heapStats::decStats(int updateU, int updateA)
{
assert(updateU >= 0);
assert(updateA >= 0);
assert(U <= A);
assert(U >= updateU);
assert(A >= updateA);
U -= updateU;
A -= updateA;
assert(U <= A);
assert(U >= 0);
assert(A >= 0);
}
inline void
heapStats::decUStats(int &Uout, int &Aout)
{
assert(U <= A);
assert(U > 0);
assert(A >= 0);
U--;
Uout = U;
Aout = A;
assert(U >= 0);
assert(A >= 0);
}
inline void
heapStats::decUStats(void)
{
assert(U <= A);
assert(U > 0);
assert(A >= 0);
U--;
}
inline void
heapStats::getStats(int &Uout, int &Aout)
{
assert(U >= 0);
assert(A >= 0);
Uout = U;
Aout = A;
assert(U <= A);
assert(U >= 0);
assert(A >= 0);
}
#if HEAP_STATS
inline int
heapStats::getUmax(void)
{
return Umax;
}
inline int
heapStats::getAmax(void)
{
return Amax;
}
#endif
#endif