-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.h
44 lines (36 loc) · 1.2 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef ADS_UTILS_H
#define ADS_UTILS_H
#include <stdlib.h>
namespace ADS
{
class PQueue;
void * allocateArray (unsigned int uiLen, unsigned int uiElementSize);
void * reallocateArray (void *pArray, unsigned int uiCurrLen,
unsigned int uiNewLen, unsigned int uiElementSize);
void setArray (int iDefValue, void *pArray, unsigned int uiLen,
unsigned int uiElementSize);
void deallocate (void **ppPtr);
template <class T>
void deallocateObjPtrArray (T ***pppPtr, unsigned int uiLen)
{
for (unsigned int i = 0; i < uiLen; i++)
delete (*pppPtr)[i];
free (*pppPtr);
pppPtr = NULL;
}
void emptyQueue (PQueue *pQueue);
bool isNumber (const char *pszString);
bool isPowerOf2 (unsigned int value);
void log (const char *pszMsg, ...);
unsigned int minimum (unsigned int ui1, unsigned int ui2);
float random (unsigned int uiMax);
float random (unsigned int uiMin, unsigned int uiMax);
char * strDup (const char *pszString);
template<class T> void swap (T *&pEl1, T *&pEl2)
{
T *pTmp = pEl1;
pEl1 = pEl2;
pEl2 = pTmp;
}
}
#endif /* ADS_UTILS_H */