Persistent Dictionaries ExampleThe following program shows how #include <LEDA/core/p_dictionary.h> #include <LEDA/core/string.h> using namespace leda; int main() { p_dictionary<string, int> PD; //objects of type int, keys of type string p_dictionary<string,int> PD_backup1, PD_backup2; //used to store intermediate "states" of PD PD.insert("alpha",1); PD.insert("beta",2); PD_backup1=PD.insert("gamma",3); //store p_dictionary after insertion of <"gamma",3> PD.insert("delta",4); PD_backup2=PD.del("beta"); //store p_dictionary after deletion of <"beta",2> PD_backup2=PD.insert("psi",10); //copies of PD can be changed independently PD.insert("epsilon",5); if (PD.locate("beta")) std::cout << "beta is contained in PD\n"; else std::cout << "beta is not contained in PD\n"; if (PD_backup1.locate("beta")) std::cout << "beta is contained in PD_backup1\n"; else std::cout << "beta is not contained in PD_backup1\n"; if (PD_backup2.locate("beta")) std::cout << "beta is contained in PD_backup2\n"; else std::cout << "beta is not contained in PD_backup2\n"; return 0; } |
See also:Partially Persistent Dictionary Manual Entries: Manual Page Persistent Dictionaries |