Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string>
- #include <map>
- #include "Persitent_tree.h"
- #include "node.h"
- template <class Data>
- std::map<std::string,Tree<Data> > tag_Revision (const std::string & tag, Tree<Data> a, std::map<std::string,Tree<Data> > tr)
- {
- tr.insert(std::make_pair(tag,a));
- return tr;
- }
- template <class Data>
- std::map<std::string,Tree<Data> > remove_Revision (const std::string & tag, std::map<std::string,Tree<Data> > tr)
- {
- tr.erase(tag);
- return tr;
- }
- int main()
- {
- std::map<std::string,Tree<int> > tr;
- Tree<int> tree = Tree<int>();
- tree.addkey(1);
- tree.addkey(2);
- tree.addkey(3);
- tr = tag_Revision("first",tree,tr);
- std::map<std::string,Tree<int> >::iterator it = tr.find("first");
- Tree<int> other = it->second;
- other.addkey(5);
- other.addkey(4);
- tag_Revision("second",other, tr);
- it = tr.find("second");
- it = tr.find("first");
- it->second;
- tree.print();
- std::cout << std::endl;
- std::cout << tree.contains_key(3);
- return 0;
- }
Add Comment
Please, Sign In to add comment