Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Destructor/Constructors
- template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
- BSTMap<KEY,T,tlt>::~BSTMap() {
- delete_BST(map);
- }
- template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
- BSTMap<KEY,T,tlt>::BSTMap(bool (*clt)(const KEY& a, const KEY& b))
- : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt) {
- if (tlt != (ltfunc) undefinedlt < KEY > && clt != (ltfunc) undefinedlt < KEY > && tlt != clt)
- throw TemplateFunctionError("BSTMap::default constructor: both specified and different");
- if (lt == (ltfunc) undefinedlt < KEY >)
- throw TemplateFunctionError("BSTMAP::default constructor: neither specified");
- }
- template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
- BSTMap<KEY,T,tlt>::BSTMap(const BSTMap<KEY,T,tlt>& to_copy, bool (*clt)(const KEY& a, const KEY& b))
- : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt){
- if (lt == (ltfunc)undefinedlt<KEY>)
- lt = to_copy.lt;
- if (lt == to_copy.lt) {
- used = to_copy.used;
- map = copy(to_copy.map);
- }
- else{
- for (auto i : to_copy)
- put(i.first, i.second);
- }
- }
- template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
- BSTMap<KEY,T,tlt>::BSTMap(const std::initializer_list<Entry>& il, bool (*clt)(const KEY& a, const KEY& b))
- : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt){
- if (lt == (ltfunc)undefinedlt<KEY>)
- throw TemplateFunctionError("BSTMap::iterable constructor: neither specified");
- for (const Entry& m_entry : il)
- put(m_entry.first,m_entry.second);
- }
- template<class KEY,class T, bool (*tlt)(const KEY& a, const KEY& b)>
- template <class Iterable>
- BSTMap<KEY,T,tlt>::BSTMap(const Iterable& i, bool (*clt)(const KEY& a, const KEY& b))
- : lt(tlt != (ltfunc)undefinedlt<KEY> ? tlt : clt){
- if (lt == (ltfunc)undefinedlt<KEY>)
- throw TemplateFunctionError("BSTMAP::iterable constructor: neither specified");
- if (tlt != (ltfunc)undefinedlt<KEY> && clt != (ltfunc)undefinedlt<KEY> && tlt != clt)
- throw TemplateFunctionError("BSTMAP::iterable constructor: both specified");
- for (const Entry& m_entry : i)
- put(m_entry.first,m_entry.second);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement