C++ Haffman coding