This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Recently I was discussing with some friends how to implement Huffman compression. When a Huffman tree is being constructed, "available" nodes are kept in a pile, and nodes with the lowest weight must be repeatedly removed, while new nodes are inserted.
After a bit of thinking, we arrived at this:
std::priority_queue<Node *, std::vector<Node *>, boost::function<bool (Node *, Node *)> > available_nodes(*_1 > *_2);
Now, that's certainly... subtle, but it simplifies greatly the following code.
-- Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290 Saturnushof 14, 3738 XG Maartensdijk, The Netherlands Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |