Example #1
0
// Copies the entire cache to a MathTree
MathTree* Parser::cache_to_tree(Node* root)
{
    MathTree* tree = new MathTree();
    list<Node*>::iterator it;
    for (unsigned weight = 0; weight < node_cache.size(); ++weight)
        for (int op = 0; op < LAST_OP; ++op)
            for (it = node_cache[weight][op].begin();
                 it != node_cache[weight][op].end(); ++it)
                tree->add(*it);
    tree->pack();
    tree->set_root(root);
    cout << "Done." << endl;
    return tree;
}