-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfull_list.cpp
46 lines (37 loc) · 1.09 KB
/
full_list.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "vote.hpp"
#include "partylist.cpp"
#include "settings.h"
#pragma once
namespace panachage
{
class FullListVote : public Vote
{
partylist *plist;
public:
void count(std::vector<partylist *> lists)
{
for (auto c : plist->candidate_votes)
{
candidate::id_type id = c.first;
plist->candidate_votes[id] += this->copies;
}
plist->at_large_votes += (config.seats - plist->candidate_votes.size()) * this->copies;
}
inline bool validate()
{
return true;
}
inline bool operator<(const Vote &vote) const
{
const FullListVote *f = dynamic_cast<const FullListVote *>(&vote);
if (!f)
return true;
return this->plist->id < f->plist->id;
}
inline std::string encode() const
{
return (copies == 1 ? "" : std::to_string(copies) + "*") + "f|" + std::to_string(plist->id);
}
inline FullListVote(partylist *plist) : plist(plist) {}
};
}