From: Ricardo Markiewicz Date: Wed, 14 Sep 2005 04:33:05 +0000 (+0000) Subject: Agrego operadores a las claves X-Git-Tag: 1_0-pre1~134 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/78ac68dcad2dc4582213848e8d1a98e3b16abff1?ds=sidebyside Agrego operadores a las claves --- diff --git a/src/clave.h b/src/clave.h index be75a7c..18afab7 100644 --- a/src/clave.h +++ b/src/clave.h @@ -4,6 +4,7 @@ /* Clave para agregar a un arbol B */ #include "common.h" +#include class Clave { public: @@ -12,6 +13,9 @@ class Clave { virtual uint Size () const = 0; virtual uchar *ToArray () const = 0; virtual Clave *Clone () const = 0; + + virtual bool operator < (const Clave &k) const = 0; + virtual operator std::string () const = 0; }; #endif diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp index 67edc4c..5a547eb 100644 --- a/src/clave_fija.cpp +++ b/src/clave_fija.cpp @@ -31,3 +31,8 @@ Clave *ClaveFija::Clone () const return k; } +bool ClaveFija::operator < (const Clave &c) const +{ + return data < ((ClaveFija&)c).data; +} + diff --git a/src/clave_fija.h b/src/clave_fija.h index 280f24b..5997931 100644 --- a/src/clave_fija.h +++ b/src/clave_fija.h @@ -3,6 +3,8 @@ #define _CLAVE_FIJA_H_ #include "clave.h" +#include +#include class ClaveFija : public Clave { public : @@ -14,6 +16,14 @@ class ClaveFija : public Clave { uchar *ToArray () const; Clave *Clone () const; + virtual bool operator < (const Clave &c) const; + virtual operator std::string () const { + std::string out; + std::stringstream ss; + ss << data; + ss >> out; + return out; + } private: int data; };