|
![](/i/fill.gif) |
Warp wrote:
> Orchid XP v8 <voi### [at] dev null> wrote:
>> I was thinking maybe I'd try implementing a Huffman coder.
>
> That sounds like a bit advanced... :)
All my programs are! ;-)
>> I need a
>> binary tree for that. Does STL happen to have one already? (That would
>> obviously be the simplest thing...)
>
> std::set (as well as std::map) is internally implemented as a balanced
> binary tree, but if I'm not mistaken, a Huffman coder requires an
> unbalanced one, so it may be unusable for that purpose.
>
> But yeah, if you need to create your own dynamic data containers, it
> inevitably means you will have to deal with pointers, 'new' and explicit
> memory management. (Although using smart pointers may by possible in
> this situation.)
Actually, thinking about it... I don't "really" need the tree, all I
need is the tree addresses. I could represent each "tree" as just a
vector of symbol/codeword pairs, and "join trees" by frobbing the
codewords and joining the vectors.
Oh, er... can you have a vector of vectors? Or would it have to be a
vector of vector pointers?
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |