From f394d7d95de33fea2b476248ac129488643beb77 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 13 Sep 2005 16:02:16 +0000 Subject: [PATCH] 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. --- src/btree.cpp | 2 ++ src/clave.h | 5 +++-- src/clave_fija.cpp | 6 ++++++ src/clave_fija.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) 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; -- 2.43.0