#ifndef MEAPUTILS_H #define MEAPUTILS_H #include #include "intmeap.h" namespace MeapUtils { /** * Given a zero-based index of a node in a heap, return the zero-based index of * its parent. */ IntMeap::index_type get_parent_index( IntMeap::index_type index ); /** * Given a zero-based index of a node in a heap, return the zero-based index of * its left child. */ IntMeap::index_type get_left_child_index( IntMeap::index_type index ); /** * Given a zero-based index of a left node in a heap, return the zero-based * index of its sibling (the right child of its parent). */ IntMeap::index_type get_right_sibling_index( IntMeap::index_type left_child_index ); IntMeap::const_iterator index_to_it( const IntMeap& meap, IntMeap::index_type index ); IntMeap::index_type it_to_index( const IntMeap& meap, IntMeap::const_iterator it ); /** * Swap two values in a container based on their indices. */ void swap_values( IntMeap::container_type& values, IntMeap::index_type i1, IntMeap::index_type i2 ); void print_meap( const IntMeap& meap, std::ostream& out ); } #endif