codice:
// Compiled with: i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367)
#include <iostream>
#include <map>
#include <string>
namespace ig{
struct DatiAggiornamentoPermanenzaVO{
int test;
};
typedef std::string String;
typedef std::map <String, DatiAggiornamentoPermanenzaVO> Map;
class DatiAggiornamentoPermanenzaLista{
private:
static Map elencoSMS;
public:
static void addElem (const DatiAggiornamentoPermanenzaVO &elem, const String &key){
elencoSMS[key] = elem;
}
static void removeElem (const String &key){
elencoSMS.erase (key);
}
static DatiAggiornamentoPermanenzaVO getElem (const String &key){
return elencoSMS[key];
}
static int getSizeLista() {
return elencoSMS.size();
}
};
// necessary because it is static in class declaration
Map DatiAggiornamentoPermanenzaLista::elencoSMS;
}
int main (int argc, char * const argv[]){
const ig:: DatiAggiornamentoPermanenzaVO el1={1};
const ig:: DatiAggiornamentoPermanenzaVO el2={2};
ig:: DatiAggiornamentoPermanenzaLista lista;
lista.addElem (el1, "uno");
lista.addElem (el2, "due");
lista.removeElem ("uno");
std::cout << lista.getSizeLista () << std::endl;
return 0;
}