Exemple #1
0
vector<string> findItinerary(vector<pair<string, string>> tickets) {

    map<string, vector< pair<bool,string> > > g;
    int tot=1;
    for( auto p: tickets)
    {
        g[p.first].push_back(pair<bool,string>(false,p.second));
        tot++;
    }

    vector<string> itn(1,"JFK");
    travel(g,itn,tot);
    return itn;

}
Exemple #2
0
// synchronize all in todir, current packages are 'nodes'
void BrowserNode::synchronize(QDir & todir, Q3Dict<BrowserNode> & nodes)
{
    static Q3Dict<void> useful(9973);	// all useful files
    static bool made_useful = TRUE;	// set at the first call

    // compare nodes with young packages

    Q3DictIterator<BrowserNode> ity(Youngs);

    for (; ity.current(); ++ity) {
        BrowserNode * from = ity.current();
        BrowserNode * curr_bn = nodes.find(ity.currentKey());

        if ((curr_bn == 0) || (curr_bn->state == Old)) {
            // don't exist or must be updated
            if (made_useful)
                useful.insert(ity.currentKey(), (void *) 1);

            QDir & fromdir = from->view->get_dir();

            // copy package file
            copy(fromdir, todir, from->filename);

            // copy diagrams files
            QStringList::Iterator its;
            QStringList & diags = from->diagrams;

            if (made_useful) {
                for (its = diags.begin(); its != diags.end(); ++its) {
                    copy_if_needed(fromdir, todir, *its);
                    useful.insert(*its, (void *) 1);
                }
            }
            else
                for (its = diags.begin(); its != diags.end(); ++its)
                    copy_if_needed(fromdir, todir, *its);

            // copy class body files
            QStringList & cls = from->classes;

            if (made_useful) {
                for (its = cls.begin(); its != cls.end(); ++its) {
                    copy_if_needed(fromdir, todir, *its);
                    useful.insert(*its, (void *) 1);
                }
            }
            else
                for (its = cls.begin(); its != cls.end(); ++its)
                    copy_if_needed(fromdir, todir, *its);

            if (from->parent() == 0) {
                // project, special files
                copy_if_needed(fromdir, todir, "cpp_includes");
                copy_if_needed(fromdir, todir, "idl_includes");
                copy_if_needed(fromdir, todir, "java_imports");
                copy_if_needed(fromdir, todir, "generation_settings");
                copy_if_needed(fromdir, todir, "import");
                copy_if_needed(fromdir, todir, "include");
                copy_if_needed(fromdir, todir, "stereotypes");
                copy_if_needed(fromdir, todir, "tools");
            }
        }
        else if (made_useful)
            // young, memorize packages, diagrams and classes body file
            from->memo(useful);
    }

    if (made_useful) {
        // memorize up to date packages, diagrams and classes body file
        Q3DictIterator<BrowserNode> itn(nodes);

        for (; itn.current(); ++itn)
            if (itn.current()->state == UpToDate)
                itn.current()->memo(useful);

        made_useful = FALSE;
    }

    // remove files associated to deleted elements
    purge(todir, useful);
}