Grafalgo
Library of useful data structures and algorithms
|
00001 00009 #include "Adt.h" 00010 00011 namespace grafalgo { 00012 00027 bool Adt::readItem(istream& in, index& x) { 00028 Util::skipSpace(in); 00029 char c = in.peek(); 00030 if (!in.good()) return false; 00031 if (islower(c)) { 00032 x = (c - 'a') + 1; c = in.get(); return in.good(); 00033 } else if (isdigit(c)) { 00034 in >> x; return in.good(); 00035 } 00036 return false; 00037 } 00038 00039 string& Adt::item2string(index x, string& s) const { 00040 stringstream ss; 00041 if (n() <= 26) ss << ((char) ((x-1) + 'a')); 00042 else ss << x; 00043 s = ss.str(); return s; 00044 } 00045 00046 00047 } // ends namespace