37int keys [] = { 36, 32, 4, 12, 52, 59, 2, 2, 26, 1 };
46 std::memset(
buf, 0,
sizeof(
buf));
51 virtual void foo() = 0;
96 n =
static_cast<unsigned int>(
atoi(
argv[1]));
99 cout <<
"Testing with predefined keys array" <<
endl;
105 cout <<
"Predefined keys heap size: " << heap.
size() <<
endl;
110 unsigned int i, value;
112 for (i = 0; i < n; i++)
115 cout << value <<
", ";
122 <<
"Sum = " << heap.
fold(0, [] (
const int acu,
const int i)
131 cout <<
"testing with pointers" <<
endl;
134 unsigned int i, value;
137 for (i = 0; i < n; i++)
140 ptr =
new unsigned int;
142 cout << value <<
", ";
147 <<
"Extracting from heap" <<
endl;
149 for (i = 0; i < n; i++)
153 cout << value <<
" ";
161 cout <<
"testing with pointers to record" <<
endl;
164 unsigned int i, value;
167 for (i = 0; i < n; i++)
170 ptr =
new Rec(value);
171 cout << value <<
", ";
176 <<
"Extracting from heap" <<
endl;
178 for (i = 0; i < n; i++)
182 cout << value <<
" ";
#define MESSAGE(format, args...)
Print an informational message (no-op when MESSAGES is not defined).
Dynamic heap of elements of type T ordered by a comparison functor.
T getMin()
Remove the minimum element (according to Compare) and return it.
T & insert(const T &item)
Insert a copy of item into the heap.
virtual bool verify_heap(Node *p) const
const size_t & size() const noexcept
T fold(const T &init, Operation &operation) const
Simplified version of foldl() where the folded type is the same type of elements stored in the contai...
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
bool operator()(unsigned int *p1, unsigned int *p2) const
bool operator()(const Record &l, const Record &r) const
Dynamic binary heap with node-based storage.