basix_doc 0.1
|
/****************************************************************************** * MODULE : heap_test.cc * DESCRIPTION: Test heaps * COPYRIGHT : (C) 2003 Joris van der Hoeven ******************************************************************************* * This software falls under the GNU general public license and comes WITHOUT * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details. * If you don't have this file, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************/ #include <basix/heap.hpp> using namespace mmx; static bool compare_int (const int& x, const int& y) { return x <= y; } int main () { heap<int> h (compare_int); mmout << "h\t= " << h << "\n"; h << 3; mmout << "Push\t: " << 3 << "\n"; mmout << "h\t= " << h << "\n"; h << 1; mmout << "Push\t: " << 1 << "\n"; mmout << "h\t= " << h << "\n"; h << 7; mmout << "Push\t: " << 7 << "\n"; mmout << "h\t= " << h << "\n"; h << 2; mmout << "Push\t: " << 2 << "\n"; mmout << "h\t= " << h << "\n"; mmout << "Pull\t: " << pull (h) << "\n"; mmout << "h\t= " << h << "\n"; h << 9; mmout << "Push\t: " << 9 << "\n"; mmout << "h\t= " << h << "\n"; h << 6; mmout << "Push\t: " << 6 << "\n"; mmout << "h\t= " << h << "\n"; set_top (h, 11); mmout << "Set_top\t: " << 11 << "\n"; mmout << "h\t= " << h << "\n"; heap<int> i= h; mmout << "i\t= " << i << "\n"; mmout << "h=i\t? " << (h==i) << "\n"; mmout << "h!=i\t? " << (h!=i) << "\n"; h << 9 << 8 << 7 << 6 << 5; mmout << "Push\t: 9, 8, 7, 6, 5\n"; mmout << "h\t= " << h << "\n"; mmout << "h=i\t? " << (h==i) << "\n"; mmout << "h!=i\t? " << (h!=i) << "\n"; mmout << "h...\t= " << iterate (h) << "\n"; return 0; }