X-Git-Url: https://git.llucax.com/z.facultad/75.68/celdas.git/blobdiff_plain/38146f219b98da8c9de845337b83a0bf8716c83d..6566954a731b998269a9f17108ece63b17ccbbbf:/trunk/src/indicemagico.h?ds=inline diff --git a/trunk/src/indicemagico.h b/trunk/src/indicemagico.h index e52b220..01dae6d 100644 --- a/trunk/src/indicemagico.h +++ b/trunk/src/indicemagico.h @@ -9,7 +9,8 @@ #include #include -#include +#include +#include // FIXME template @@ -40,7 +41,9 @@ public: void add(CIndiceMagico& indice) { for (unsigned i = 0; i < indice.m_nombres.size(); ++i) + { add(indice.m_nombres[i], indice.m_datos[i]) ; + } } @@ -91,14 +94,12 @@ public: void remove(const std::string& nombre) { - bool exito = false ; - unsigned i; - - for (i = 0; !exito && i < m_nombres.size(); ++i) - exito = m_nombres[i]==nombre; - - if (exito) - remove(i); + for (unsigned i = 0; i < m_nombres.size(); ++i) + if (m_nombres[i]==nombre) + { + remove(i); + return; + } } @@ -112,6 +113,24 @@ public: }; - +template < typename T > +std::ostream& operator<< (std::ostream& os, CIndiceMagico& im) +{ + unsigned c = im.count(); + if (c == 0) return os << "\t\tvacío\n"; + for (unsigned i = 0; i < c; ++i) + os << "\t\t" << im.keys(i) << ":\t" << im[i] << "\n"; + return os; +} + +template < typename T > +std::ostream& operator<< (std::ostream& os, CIndiceMagico& im) +{ + unsigned c = im.count(); + if (c == 0) return os << "\t\tvacío\n"; + for (unsigned i = 0; i < c; ++i) + os << "\t\t" << im.keys(i) << ":\t" << *im[i] << "\n"; + return os; +} #endif