Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. //Destructor/Constructors
  2.  
  3. template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
  4. BSTMap<KEY,T,tlt>::~BSTMap() {
  5. delete_BST(map);
  6. }
  7.  
  8.  
  9. template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
  10. BSTMap<KEY,T,tlt>::BSTMap(bool (*clt)(const KEY& a, const KEY& b))
  11. : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt) {
  12. if (tlt != (ltfunc) undefinedlt < KEY > && clt != (ltfunc) undefinedlt < KEY > && tlt != clt)
  13. throw TemplateFunctionError("BSTMap::default constructor: both specified and different");
  14. if (lt == (ltfunc) undefinedlt < KEY >)
  15. throw TemplateFunctionError("BSTMAP::default constructor: neither specified");
  16. }
  17.  
  18.  
  19. template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
  20. BSTMap<KEY,T,tlt>::BSTMap(const BSTMap<KEY,T,tlt>& to_copy, bool (*clt)(const KEY& a, const KEY& b))
  21. : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt){
  22. if (lt == (ltfunc)undefinedlt<KEY>)
  23. lt = to_copy.lt;
  24. if (lt == to_copy.lt) {
  25. used = to_copy.used;
  26. map = copy(to_copy.map);
  27. }
  28. else{
  29. for (auto i : to_copy)
  30. put(i.first, i.second);
  31. }
  32. }
  33.  
  34.  
  35. template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
  36. BSTMap<KEY,T,tlt>::BSTMap(const std::initializer_list<Entry>& il, bool (*clt)(const KEY& a, const KEY& b))
  37. : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt){
  38. if (lt == (ltfunc)undefinedlt<KEY>)
  39. throw TemplateFunctionError("BSTMap::iterable constructor: neither specified");
  40. for (const Entry& m_entry : il)
  41. put(m_entry.first,m_entry.second);
  42. }
  43.  
  44.  
  45. template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
  46. template <class Iterable>
  47. BSTMap<KEY,T,tlt>::BSTMap(const Iterable& i, bool (*clt)(const KEY& a, const KEY& b))
  48. : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt){
  49. if (lt == (ltfunc)undefinedlt<KEY>)
  50. throw TemplateFunctionError("BSTMAP::iterable constructor: neither specified");
  51. if (tlt != (ltfunc)undefinedlt<KEY> && clt != (ltfunc)undefinedlt<KEY> && tlt != clt)
  52. throw TemplateFunctionError("BSTMAP::iterable constructor: both specified");
  53. for (const Entry& m_entry : i)
  54. put(m_entry.first,m_entry.second);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement