I am getting error "no match for operator==in__first. Here is the code:
header file:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
struct rankingElement {
string url;
int rank;
};
class RankingCreator {
public:
static const int MAX_QUERY_SIZE = 20;
RankingCreator();
virtual ~RankingCreator();
bool checkPageRank(rankingElement rElement, vector<rankingElement> ranking);
void insertIntoRanking(rankingElement rElement);
};
And source file :
#include "RankingCreator.h"
bool RankingCreator::checkPageRank(rankingElement rElement,
vector<rankingElement> ranking)
{
if (ranking.size() < MAX_QUERY_SIZE) {
// enough space for another page in ranking
return true;
} else {
if (find(ranking.begin(), ranking.end(), rElement.url) != ranking.end()) {
// url is already in ranking
return false;
} else {
}
}
return true;
}
I tried commenting some blocks of code in source file and the line with find() function seems to generate the errors. It is function from class algorithm used to check whether a vector already contains certain element. I found out that it is wrong, because I try to compare struct with string in find function. I can handle that by copying urls from ranking to another vector of string and then use that vector of strings in find function, but when I tried to do that I can't access elements in 'ranking' vector - for instance ranking[i].url doesn't work and I don't know why.. and help would be appreciated.