40 #ifndef _cvc3__minisat__global_h_
41 #define _cvc3__minisat__global_h_
58 template<
class T>
static inline T
min(T x, T y) {
return (x < y) ? x : y; }
59 template<
class T>
static inline T
max(T x, T y) {
return (x > y) ? x : y; }
63 #define TEMPLATE_FAIL STATIC_ASSERTION_FAILURE<false>()
70 template<
class T>
static inline T*
xmalloc(
size_t size) {
71 T* tmp = (T*)malloc(size *
sizeof(T));
72 DebugAssert(size == 0 || tmp != NULL,
"Minisat::Global::xmalloc");
75 template<
class T>
static inline T*
xrealloc(T* ptr,
size_t size) {
76 T* tmp = (T*)realloc((
void*)ptr, size *
sizeof(T));
77 DebugAssert(size == 0 || tmp != NULL,
"Minisat::Global::xrealloc");
80 template<
class T>
static inline void xfree(T *ptr) {
81 if (ptr != NULL) free((
void*)ptr); }
89 static inline double drand(
double& seed) {
91 int q = (int)(seed / 2147483647);
92 seed -= (double)q * 2147483647;
93 return seed / 2147483647; }
96 static inline int irand(
double& seed,
int size) {
97 return (
int)(
drand(seed) * size); }
114 void grow(
int min_cap);
130 operator T* (void) {
return data; }
131 operator const T* (void)
const {
return data; }
136 for (
int i = 0; i < nelems; i++)
sz--,
data[
sz].~T(); }
140 void clear (
bool dealloc =
false);
164 if (min_cap <= cap)
return;
165 if (cap == 0) cap = (min_cap >= 2) ? min_cap : 2;
166 else do cap = (cap*3+1) >> 1;
while (cap < min_cap);
171 if (sz >= size)
return;
173 for (
int i = sz; i < size; i++)
new (&data[i]) T(pad);
178 if (sz >= size)
return;
180 for (
int i = sz; i < size; i++)
new (&data[i]) T();
186 for (
int i = 0; i < sz; i++) data[i].~T();
188 if (dealloc)
xfree(data), data = NULL, cap = 0; } }
223 #ifndef __SGI_STL_INTERNAL_RELOPS // (be aware of SGI's STL implementation...)
224 #define __SGI_STL_INTERNAL_RELOPS
225 template <
class T>
static inline bool operator != (
const T& x,
const T& y) {
return !(x == y); }
226 template <
class T>
static inline bool operator > (
const T& x,
const T& y) {
return y < x; }
227 template <
class T>
static inline bool operator <= (
const T& x,
const T& y) {
return !(y < x); }
228 template <
class T>
static inline bool operator >= (
const T& x,
const T& y) {
return !(x < y); }