summaryrefslogtreecommitdiff
path: root/src/candidates-containers.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/candidates-containers.ads')
-rw-r--r--src/candidates-containers.ads23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/candidates-containers.ads b/src/candidates-containers.ads
index 3d9d3f9..b83093a 100644
--- a/src/candidates-containers.ads
+++ b/src/candidates-containers.ads
@@ -2,6 +2,7 @@
with
+ Ada.Containers.Vectors,
Ada.Containers.Ordered_Maps,
Ada.Containers.Ordered_Sets;
@@ -9,31 +10,37 @@ with
package Candidates.Containers is
- package Candidate_Maps is new Ada.Containers.Ordered_Maps
- (Key_Type => CandidateID,
+ -- By making this a Vector, later generics will be able to
+ -- determine the range of valid CandidateIDs.
+ package Candidate_Vectors is new Ada.Containers.Vectors
+ (Index_Type => CandidateID,
Element_Type => Candidate);
- subtype Candidate_Map is Candidate_Maps.Map;
+ subtype Candidate_Vector is Candidate_Vectors.Vector;
procedure Read_Candidates
(Filename : in String;
State : in State_Name;
- Candidate_Data : out Candidate_Map);
+ Candidate_Data : out Candidate_Vector);
+ -- This must be a Map so that the Index/Key doesn't have to start
+ -- from 1, which is important for the Above_Line_Ballot type.
package CandidateID_Maps is new Ada.Containers.Ordered_Maps
(Key_Type => Positive,
Element_Type => CandidateID);
- use type CandidateID_Maps.Map;
+ -- Technically doesn't have to be a Map, but nonetheless is,
+ -- simply for consistency with CandidateID_Maps.
package CandidateID_Map_Maps is new Ada.Containers.Ordered_Maps
(Key_Type => Positive,
- Element_Type => CandidateID_Maps.Map);
+ Element_Type => CandidateID_Maps.Map,
+ "=" => CandidateID_Maps."=");
-- Possibly put some aspects here to ensure the types are as expected?
@@ -42,7 +49,7 @@ package Candidates.Containers is
procedure Generate_Ballots
- (Candidate_Data : in Candidate_Map;
+ (Candidate_Data : in Candidate_Vector;
Above_Ballot : out Above_Line_Ballot;
Below_Ballot : out Below_Line_Ballot);
@@ -61,6 +68,8 @@ package Candidates.Containers is
+ -- Used for passing the CandidateIDs that have been elected, excluded, etc,
+ -- around to various functions when calculating the election.
package CandidateID_Sets is new Ada.Containers.Ordered_Sets
(Element_Type => CandidateID);