#include <string>
#include <vector>
#include <ostream>
+#include <iostream> // FIXME
template <class T>
void add(CIndiceMagico<T>& indice)
{
for (unsigned i = 0; i < indice.m_nombres.size(); ++i)
+ {
add(indice.m_nombres[i], indice.m_datos[i]) ;
+ }
}
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;
+ }
}
};
template < typename T >
+inline
std::ostream& operator<< (std::ostream& os, CIndiceMagico<T>& im)
{
- for (unsigned i = 0; i < im.count(); ++i)
- os << "\t" << im.keys(i) << "=" << im[i] << "\n";
+ unsigned c = im.count();
+#ifdef LOG
+ if (c-- == 0) return os << "";
+ for (unsigned i = 0; i < c; ++i)
+ os << im[i] << ",";
+ os << im[c];
+ return os;
+#else // ! LOG
+ 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 // LOG
+}
+
+template < typename T >
+inline
+std::ostream& operator<< (std::ostream& os, CIndiceMagico<T*>& im)
+{
+ unsigned c = im.count();
+#ifdef LOG
+ if (c-- == 0) return os << "";
+ for (unsigned i = 0; i < c; ++i)
+ os << *im[i] << ",";
+ os << *im[c];
+ return os;
+#else // ! LOG
+ 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 // LOG
}
#endif