Technologies.Cpp

Comparing C++ And Perl

#include "Technologies.h"

using namespace std;

Technologies::Technologies(){
    technologies.push_back("ntruencrypt");
    technologies.push_back("ntrusign");
    technologies.push_back("lattice_reduction");
    technologies.push_back("implementations");
    technologies.push_back("variants");

    for (int i=0; i < technologies.size(); i++){
        tech_order.insert(
            pair <string, int> (technologies[i], i));
    }
}

Technologies::~Technologies(){
}

size_t Technologies::size() const {
    return technologies.size();
}

string Technologies::operator[](int i) const {
    return technologies[i];
}

bool Technologies::entry_num(string const &s, int& n) const {
    map <string, int>::const_iterator it = tech_order.find(s);
    if (it == tech_order.end()){
        return false;
    }
    n = it->second;
    return true;
}

Wednesday, April 29, 2009 (1)