|
/* Begin Student Code */
#ifndef SHILL_BID_ANALYSIS_H
#define SHILL_BID_ANALYSIS_H
#include <iostream>
#include <map>
#include <set>
#include <string>
#include "Advertisement.h"
#include "Listing.h"
using namespace std;
class ShillBidAnalysis {
private:
map<string, set<Advertisement*> > bidders;
map<string, set<Advertisement*> > posters;
void convertRepresentation(Listing& listing);
public:
ShillBidAnalysis(Listing& listing);
void showShillBidders(void);
};
#endif
/* End Student Code */
Identifying Shill Bidders2
ShillBidAnalysis.cpp
/* Begin Student Code */
#pragma warning (disable: 4786)
#include "ShillBidAnalysis.h"
#include <numeric>
#include <functional>
using namespace std;
ShillBidAnalysis::ShillBidAnalysis(Listing& listing) {
convertRepresentation(listing);
}
void ShillBidAnalysis::convertRepresentation (Listing& listing) {
Listing::iterator it = listing.begin();
while (it!= listing.end()) {
Advertisement* ad = *it;
priority_queue<Bid> bids = ad->getBids();
vector<string> this_ad;
posters[ad->getEmail()].insert(ad);
// ignore bids placed by auction winner
string winner;
if (bids.size() > 0) {
winner = bids.top().getEmail();
bids.pop();
}
while (!bids.empty()) {
string bidder = bids.top().getEmail();
if (bidder!= winner) {
bidders[bidder].insert(ad);
}
bids.pop();
}
it++;
}
}
void ShillBidAnalysis::showShillBidders(void) {
map<string, set<Advertisement*> >::iterator bid_it;
map<string, set<Advertisement*> >::iterator post_it;
for (post_it = posters.begin(); post_it!= posters.end(); post_it++) {
if (post_it->second.size() > 1) {
cout << "\n" << post_it->first << " (" << post_it->second.size()
<< "): ";
for (bid_it = bidders.begin(); bid_it!= bidders.end(); bid_it++) {
if (includes(bid_it->second.begin(), bid_it->second.end(),
post_it->second.begin(), post_it->second.end())) {
cout << bid_it->first << " ";
}
}
}
}
}
/* End Student Code */
Дата добавления: 2015-11-14; просмотров: 52 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
BiddingWarAnalysis.h | | | Certificate Application List 2013 Bobruisk |