From: Ricardo Markiewicz Date: Tue, 13 Sep 2005 16:02:16 +0000 (+0000) Subject: Agrego Clone a las claves. X-Git-Tag: 1_0-pre1~144 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/f394d7d95de33fea2b476248ac129488643beb77?ds=inline Agrego Clone a las claves. Como el ctor de copia no me sirve dado la herencia, necesito una forma de clonar claves independientemente de su tipo. --- diff --git a/src/btree.cpp b/src/btree.cpp index c7d3b4b..21609bf 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -62,6 +62,8 @@ void BTree::AddKey (const Clave &k) if (root_header.free_space >= k.Size ()) { std::cout << "Hay lugar para meter la clave" << std::endl; + /* TODO : Insertar ordenado */ + node_keys.push_back (k.Clone ()); } else { std::cout << "__NO__ hay lugar para meter la clave" << std::endl; } diff --git a/src/clave.h b/src/clave.h index 7cf3ceb..be75a7c 100644 --- a/src/clave.h +++ b/src/clave.h @@ -9,8 +9,9 @@ class Clave { public: virtual ~Clave () {} - virtual uint Size () = 0; - virtual uchar *ToArray () = 0; + virtual uint Size () const = 0; + virtual uchar *ToArray () const = 0; + virtual Clave *Clone () const = 0; }; #endif diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp index a954e24..67edc4c 100644 --- a/src/clave_fija.cpp +++ b/src/clave_fija.cpp @@ -25,3 +25,9 @@ uchar *ClaveFija::ToArray () const return out; } +Clave *ClaveFija::Clone () const +{ + ClaveFija *k = new ClaveFija (*this); + return k; +} + diff --git a/src/clave_fija.h b/src/clave_fija.h index aa6e712..280f24b 100644 --- a/src/clave_fija.h +++ b/src/clave_fija.h @@ -12,6 +12,7 @@ class ClaveFija : public Clave { uint Size () const; uchar *ToArray () const; + Clave *Clone () const; private: int data;