From 60b2207a469a5a1e7a7e5619a8eb1b01c67f314a Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 10 Feb 2017 18:41:36 +1100 Subject: Preference data reads into Bundles properly, with packed memory and a few fixed bugs --- src/candidates.ads | 123 ++--------------------------------------------------- 1 file changed, 4 insertions(+), 119 deletions(-) (limited to 'src/candidates.ads') diff --git a/src/candidates.ads b/src/candidates.ads index fe25228..fef8d4c 100644 --- a/src/candidates.ads +++ b/src/candidates.ads @@ -1,7 +1,6 @@ private with Ada.Strings.Unbounded; -private with Ada.Containers.Vectors; package Candidates is @@ -11,7 +10,10 @@ package Candidates is type Candidate is private; - type CandidateID is new Positive; + + + -- this is restricted to 255 values for memory conservation reasons + type CandidateID is new Positive range 1 .. 255; subtype Extended_CandidateID is CandidateID'Base @@ -27,94 +29,6 @@ package Candidates is 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 @@ -130,35 +44,6 @@ private 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; -- cgit