Skip to content

Instantly share code, notes, and snippets.

@chtitux
Created November 8, 2010 20:59
Show Gist options
  • Save chtitux/668262 to your computer and use it in GitHub Desktop.
Save chtitux/668262 to your computer and use it in GitHub Desktop.
/*
* Dictionary.cpp
*
* Created on: 8 nov. 2010
* Author: chtitux
*/
#include <iostream>
#include <sstream>
#include <string>
#include <stdexcept>
#include "Dictionary.h"
Dictionary::Dictionary() {
}
Dictionary::Dictionary(istream & is) {
}
void Dictionary::Flush() {
words.clear();
}
unsigned int Dictionary::Size() const {
return words.size();
}
void Dictionary::Insert(const string & key, const string & value) {
words[key] = value;
}
void Dictionary::Remove(const string & key) {
words.erase(key);
}
string Dictionary::Translate(const string & key) const {
return words.at(key);
}
istream& Dictionary::ReadFrom(istream& is) {
return is;
}
istream& Dictionary::ReadPair(istream & is) {
return is;
}
istream& operator >> (istream& is, Dictionary& dico) {
return is;
}
ostream& Dictionary::printOn(ostream & os) const {
os << "(" << Size() << ") " ;
const_iterator it = words.begin();
for(; it != words.end(); ++it) {
os << endl << (*it).first <<'\t'<< (*it).second;
// os << (*it).first << "->" << (*it).second << "," << endl;
}
os << endl;
return os;
}
ostream& Dictionary::PrintOn(ostream& os) const {
const_iterator it = words.begin();
for(;it != words.end();++it)
os << endl << (*it).first <<'\t'<< (*it).second;
return os;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment