STAR++ v0.2.2
C++ implementation of STAR voting
Loading...
Searching...
No Matches
headtoheadresults.h
1#ifndef HEADTOHEADRESULTS_H
2#define HEADTOHEADRESULTS_H
3
4// Qt Includes
5#include <QSet>
6#include <QHash>
7#include <QString>
8
9// Qx Includes
10#include <qx/core/qx-cumulation.h>
11
12namespace Star
13{
15// Forward Declarations
16class Election;
17
18class HeadToHeadResults
19{
20//-Class Enums-----------------------------------------------------------------------------------------------------
21public:
22 enum NarrowMode{ Inclusive, Exclusive };
23
24//-Inner Structs----------------------------------------------------------------------------------------------------
25private:
26 struct CandidateStats
27 {
28 QSet<QString> victories;
29 QSet<QString> defeats;
30 Qx::Cumulation<QString, int> preferences;
31 Qx::Cumulation<QString, int> antiPreferences;
32 };
33
34//-Instance Variables--------------------------------------------------------------------------------------------------
35private:
36 QHash<QString, CandidateStats> mStats;
37
38//-Constructor---------------------------------------------------------------------------------------------------------
39private:
40 HeadToHeadResults();
41
42public:
43 HeadToHeadResults(const Election* election);
44
45//-Instance Functions-------------------------------------------------------------------------------------------------
46private:
47 void faceOffStatsUpdate(const QString& can, int canPref, const QString& opp, int oppPref);
48
49public:
50 int wins(const QString& candidate) const;
51 int losses(const QString& candidate) const;
52 int preferences(const QString& candidate) const;
53 int margin(const QString& candidate) const;
54 QString winner(const QString& candidateA, const QString& candidateB) const;
55
56 qsizetype candidateCount() const;
57 QSet<QString> candidates() const;
58
59 void narrow(QSet<QString> candidates, NarrowMode mode);
60 HeadToHeadResults narrowed(QSet<QString> candidates, NarrowMode mode);
61};
63}
64
65#endif // HEADTOHEADRESULTS_H
The Star namespace is the main namespace through which all functionality of the STAR++ library is acc...
Definition calculator.cpp:21