blob: 8b76707fc27e01e33cf3b28489cbd51bd6cd14f6 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
private with Ada.Strings.Unbounded;
private with Ada.Containers.Vectors;
package Candidates is
type State_Name is (ACT, NT, TAS, SA, WA, VIC, QLD, NSW);
type Candidate is private;
type CandidateID is new Positive;
function To_String
(Input_Candidate : in Candidate;
Delimiter : in Character := ',')
return String;
type Candidate_Vector is private;
type CandidateID_Vector is private;
procedure Read_Candidates
(Filename : in String;
State : in State_Name;
Candidate_List : out Candidate_Vector);
function First
(Candidate_List : in Candidate_Vector)
return CandidateID;
function Last
(Candidate_List : in Candidate_Vector)
return CandidateID;
function Lookup
(Candidate_List : in Candidate_Vector;
Index : in CandidateID)
return Candidate;
function First
(CandidateID_List : in CandidateID_Vector)
return Positive;
function Last
(CandidateID_List : in CandidateID_Vector)
return Positive;
function Lookup
(CandidateID_List : in CandidateID_Vector;
Index : in Positive)
return CandidateID;
type Above_Line_Ballot is private;
type Below_Line_Ballot is private;
procedure Generate_Ballots
(Candidate_List : in Candidate_Vector;
Above_Ballot : out Above_Line_Ballot;
Below_Ballot : out Below_Line_Ballot);
function First
(Above_Ballot : in Above_Line_Ballot)
return Positive;
function Last
(Above_Ballot : in Above_Line_Ballot)
return Positive;
function Lookup
(Above_Ballot : in Above_Line_Ballot;
Index : in Positive)
return CandidateID_Vector;
function First
(Below_Ballot : in Below_Line_Ballot)
return Positive;
function Last
(Below_Ballot : in Below_Line_Ballot)
return Positive;
function Lookup
(Below_Ballot : in Below_Line_Ballot;
Index : in Positive)
return CandidateID;
private
package SU renames Ada.Strings.Unbounded;
type Candidate is record
First_Name : SU.Unbounded_String;
Last_Name : SU.Unbounded_String;
Group : SU.Unbounded_String;
Group_Rank : SU.Unbounded_String;
Party : SU.Unbounded_String;
end record;
package Candidate_Vectors is new Ada.Containers.Vectors
(Index_Type => CandidateID,
Element_Type => Candidate);
type Candidate_Vector is record
Vec : Candidate_Vectors.Vector;
end record;
package CandidateID_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => CandidateID);
type CandidateID_Vector is record
Vec : CandidateID_Vectors.Vector;
end record;
package Above_Line_Ballots is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => CandidateID_Vector);
type Above_Line_Ballot is record
Vec : Above_Line_Ballots.Vector;
end record;
type Below_Line_Ballot is record
Vec : CandidateID_Vectors.Vector;
end record;
end Candidates;
|