Guest User

Untitled

a guest
Jan 13th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include "Persitent_tree.h"
  5. #include "node.h"
  6.  
  7. template <class Data>
  8. std::map<std::string,Tree<Data> > tag_Revision (const std::string & tag, Tree<Data> a, std::map<std::string,Tree<Data> > tr)
  9. {
  10.    tr.insert(std::make_pair(tag,a));
  11.    return tr;
  12. }
  13.  
  14. template <class Data>
  15. std::map<std::string,Tree<Data> > remove_Revision (const std::string & tag, std::map<std::string,Tree<Data> > tr)
  16. {
  17.    tr.erase(tag);
  18.    return tr;
  19. }
  20.  
  21. int main()
  22. {
  23.    std::map<std::string,Tree<int> > tr;
  24.    Tree<int> tree = Tree<int>();
  25.    tree.addkey(1);
  26.    tree.addkey(2);
  27.    tree.addkey(3);
  28.    tr = tag_Revision("first",tree,tr);
  29.    std::map<std::string,Tree<int> >::iterator it = tr.find("first");
  30.    Tree<int> other = it->second;
  31.  
  32.    other.addkey(5);
  33.    other.addkey(4);
  34.    tag_Revision("second",other, tr);
  35.    it = tr.find("second");
  36.    it = tr.find("first");
  37.    it->second;
  38.  
  39.    tree.print();
  40.    std::cout << std::endl;
  41.    std::cout << tree.contains_key(3);
  42.    return 0;
  43. }
Add Comment
Please, Sign In to add comment