From 78ac68dcad2dc4582213848e8d1a98e3b16abff1 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Wed, 14 Sep 2005 04:33:05 +0000 Subject: [PATCH] Agrego operadores a las claves --- src/clave.h | 4 ++++ src/clave_fija.cpp | 5 +++++ src/clave_fija.h | 10 ++++++++++ 3 files changed, 19 insertions(+) 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; }; -- 2.43.0