D
devel
Hello,
Could someone tell me why the find_if statement applied to my multimap
dictionnary is doesn't compile? Does this algorithm doesn't work on a
multimap?
I don't understand why the adjacent_find compile and not the find_if
statement?
By the way my first intention was to write:
find_if (j, dictionnary.end(), bind1st (not_equal_to <string> (), *j));
but it doesn't compile neither for the same reason I guess.
Thanks by advance,
devel.
#include <iostream>
#include <map>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>
#include <functional>
using namespace std;
typedef multimap<string, string, less <string> > MapDictionnary;
int
main (int argc, char **argv)
{
string dictionnaryName;
cout << "Enter dictionnary name :";
cin >> dictionnaryName;
MapDictionnary dictionnary;
ifstream dictionnaryIFStream (dictionnaryName.c_str());
istream_iterator<string> it;
for (it=istream_iterator<string> (dictionnaryIFStream);
it!=istream_iterator<string> (); ++it)
{
vector<char> sortedString ((*it).begin(), (*it).end());
sort (sortedString.begin(), sortedString.end());
dictionnary.insert (make_pair<string, string>
(string(sortedString.begin(), sortedString.end()), (*it)));
}
cout << "The dictionnary " << dictionnaryName << " contains " <<
dictionnary.size() << " words." << endl;
MapDictionnary::iterator j=dictionnary.begin();
MapDictionnary::iterator k;
while (true)
{
j=adjacent_find (j, dictionnary.end(), dictionnary.value_comp());
if (j==dictionnary.end())
break;
// INCORECT FIND_IF STATEMENT !! k=find_if (j, dictionnary.end(),
dictionnary.value_comp());
// End of : INCORECT FIND_IF STATEMENT !!
};
return 0;
}
Could someone tell me why the find_if statement applied to my multimap
dictionnary is doesn't compile? Does this algorithm doesn't work on a
multimap?
I don't understand why the adjacent_find compile and not the find_if
statement?
By the way my first intention was to write:
find_if (j, dictionnary.end(), bind1st (not_equal_to <string> (), *j));
but it doesn't compile neither for the same reason I guess.
Thanks by advance,
devel.
#include <iostream>
#include <map>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>
#include <functional>
using namespace std;
typedef multimap<string, string, less <string> > MapDictionnary;
int
main (int argc, char **argv)
{
string dictionnaryName;
cout << "Enter dictionnary name :";
cin >> dictionnaryName;
MapDictionnary dictionnary;
ifstream dictionnaryIFStream (dictionnaryName.c_str());
istream_iterator<string> it;
for (it=istream_iterator<string> (dictionnaryIFStream);
it!=istream_iterator<string> (); ++it)
{
vector<char> sortedString ((*it).begin(), (*it).end());
sort (sortedString.begin(), sortedString.end());
dictionnary.insert (make_pair<string, string>
(string(sortedString.begin(), sortedString.end()), (*it)));
}
cout << "The dictionnary " << dictionnaryName << " contains " <<
dictionnary.size() << " words." << endl;
MapDictionnary::iterator j=dictionnary.begin();
MapDictionnary::iterator k;
while (true)
{
j=adjacent_find (j, dictionnary.end(), dictionnary.value_comp());
if (j==dictionnary.end())
break;
// INCORECT FIND_IF STATEMENT !! k=find_if (j, dictionnary.end(),
dictionnary.value_comp());
// End of : INCORECT FIND_IF STATEMENT !!
};
return 0;
}