priority_queue_container_traits.cc [plain text]
#include <iostream>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
using namespace std;
using namespace pb_ds;
using namespace pb_ds;
template<class DS_Category>
void
print_container_category(DS_Category);
template<>
void
print_container_category(binary_heap_tag)
{ cout << "Binary heap:" << endl; }
template<>
void
print_container_category(binomial_heap_tag)
{ cout << "Binomial heap:" << endl; }
template<>
void
print_container_category(rc_binomial_heap_tag)
{ cout << "Redundant-counter binomial heap:" << endl; }
template<>
void
print_container_category(pairing_heap_tag)
{ cout << "Pairing heap:" << endl; }
template<>
void
print_container_category(thin_heap_tag)
{ cout << "Thin heap:" << endl; }
template<class Invalidation_Guarantee>
void
print_invalidation_guarantee(Invalidation_Guarantee);
template<>
void
print_invalidation_guarantee(basic_invalidation_guarantee)
{
cout << "Guarantees only that found references, pointers, and "
"iterators are valid as long as the container object is not "
"modified" << endl;
}
template<>
void
print_invalidation_guarantee(point_invalidation_guarantee)
{
cout << "Guarantees that found references, pointers, and "
"point_iterators are valid even if the container object "
"is modified" << endl;
}
template<>
void
print_invalidation_guarantee(range_invalidation_guarantee)
{
cout << "Guarantees that iterators remain valid even if the "
"container object is modified" << endl;
}
void
print_split_join_can_throw(bool can)
{
if (can)
{
cout << "Can throw exceptions if split or joined" << endl;
return;
}
cout << "Cannot throw exceptions if split or joined" << endl;
}
template<class DS_Traits>
void
print_container_attributes()
{
print_container_category(typename DS_Traits::container_category());
print_invalidation_guarantee(typename DS_Traits::invalidation_guarantee());
print_split_join_can_throw(DS_Traits::split_join_can_throw);
cout << endl << endl;
}
int main()
{
{
typedef
pb_ds::priority_queue<
int,
std::less<int>,
binary_heap_tag>
t;
print_container_attributes<container_traits<t> >();
}
{
typedef
pb_ds::priority_queue<
int,
std::less<int>,
binomial_heap_tag>
t;
print_container_attributes<container_traits<t> >();
}
{
typedef
pb_ds::priority_queue<
int,
std::less<int>,
rc_binomial_heap_tag>
t;
print_container_attributes<container_traits<t> >();
}
{
typedef
pb_ds::priority_queue<
int,
std::less<int>,
pairing_heap_tag>
t;
print_container_attributes<container_traits<t> >();
}
{
typedef
pb_ds::priority_queue<
int,
std::less<int>,
thin_heap_tag>
t;
print_container_attributes<container_traits<t> >();
}
return 0;
}