24 #ifndef __TPIE_UTIL_H__
25 #define __TPIE_UTIL_H__
42 inline void unused(
const T & x) {(void)x;}
44 template <
typename T>
struct sign {
typedef T type;};
45 template <>
struct sign<uint8_t> {
typedef int8_t type;};
46 template <>
struct sign<uint16_t> {
typedef int16_t type;};
47 template <>
struct sign<uint32_t> {
typedef int32_t type;};
48 template <>
struct sign<uint64_t> {
typedef int64_t type;};
50 template <
typename T>
struct unsign {
typedef T type;};
51 template <>
struct unsign<int8_t> {
typedef uint8_t type;};
52 template <>
struct unsign<int16_t> {
typedef uint16_t type;};
53 template <>
struct unsign<int32_t> {
typedef uint32_t type;};
54 template <>
struct unsign<int64_t> {
typedef uint64_t type;};
57 const char directory_delimiter =
'\\';
59 const char directory_delimiter =
'/';
72 template <
typename child_t>
82 return static_cast<memory_size_type
>(
83 floor(static_cast<double>(size) * child_t::memory_coefficient() + child_t::memory_overhead()));
93 inline static memory_size_type
memory_fits(memory_size_type memory) {
94 return static_cast<memory_size_type
>(
95 floor((memory - child_t::memory_overhead()) / child_t::memory_coefficient()));
110 static const size_t v=1;
118 template <
typename T,
typename C>
125 if (c < n && lt(*(a+i), *(a+c)))
126 std::swap(*(a+c), *(a+i));
129 if (lt(*(a+c+1), *(a+c))) {
130 if (lt(*(a+i), *(a+c))) {
131 std::swap(*(a+c), *(a+i));
135 if (lt(*(a+i), *(a+c+1))) {
136 std::swap(*(a+c+1), *(a+i));
147 template <
typename T>
156 template <
typename T>
160 template<
typename T1,
typename T2>
161 bool operator()(
const T1 & x,
const T2 & y)
const {
164 template<
typename T1,
typename T2>
165 bool operator()(
const T1 & x,
const T2 & y) {
170 void atomic_rename(
const std::string & src,
const std::string & dst);
178 template <
typename T>
185 void throw_getlasterror();
190 #endif //__TPIE_UTIL_H__
void pop_and_push_heap(T a, T b, C lt)
Restore heap invariants after the first element has been replaced by some other element.
Base class of data structures with linear memory usage.
static memory_size_type memory_usage(memory_size_type size)
Return the number of bytes required to create a data structure supporting a given number of elements...
void unused(const T &x)
Declare that a variable is unused on purpose.
This file contains a few deprecated definitions for legacy code.
A binary functor with the arguments swapped.
static memory_size_type memory_fits(memory_size_type memory)
Return the maximum number of elements that can be contained in in the structure when it is allowed to...
Computes the least integer strictly greater than log(t).
void free_structure_memory(T &v)
Free the memory assosiated with a stl or tpie structure by swapping it with a default constructed str...