From be9b26ad909dfe973e3ef7756afae6a2b42a41d5 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 18 Feb 2017 20:46:50 +1100 Subject: Commented the Candidates packages better --- src/candidates-containers.adb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/candidates-containers.adb') diff --git a/src/candidates-containers.adb b/src/candidates-containers.adb index 9807f7a..a69a3a2 100644 --- a/src/candidates-containers.adb +++ b/src/candidates-containers.adb @@ -23,7 +23,6 @@ package body Candidates.Containers is is package My_CSV is new CSV; use Ada.Text_IO; - use type Ada.Containers.Count_Type; use type SU.Unbounded_String; Input_File : File_Type; @@ -38,9 +37,9 @@ package body Candidates.Containers is while not End_Of_File (Input_File) loop Current_Record := My_CSV.Parse_Line (Get_Line (Input_File)); - -- all the field numbers here correspond to how - -- AEC Senate candidate data is arranged in csv format - if Current_Record.Length = 25 and then + -- All the field numbers here correspond to how + -- AEC Senate candidate data is arranged in csv format. + if Integer (Current_Record.Length) = 25 and then Current_Record.Element (2) = "S" and then Current_Record.Element (3) = State_Name'Image (State) then @@ -61,9 +60,9 @@ package body Candidates.Containers is - -- these two types exist because I can't think of an easier + -- These types exist because I can't think of an easier -- way to sort a Candidate_Map into the appropriate order at - -- the moment + -- the moment. type Cand_Sort_Data is record Cand_ID : CandidateID; @@ -124,9 +123,11 @@ package body Candidates.Containers is while Current_Index <= Candidate_Data.Last_Index loop Current_Group := Candidate_Data.Element (Current_Index).Group; - -- the assumption is that the "UG" group is always last - -- a fairly safe assumption given alphabetical group order - -- but will break down should there be more than... 553 grouped candidates + -- The assumption is that the "UG" group is always last. + -- A fairly safe assumption given alphabetical group order + -- but will break down should there be more than 553 grouped candidates. + -- Fortunately, that will never happen because the CandidateIDs will + -- run out at 256 Candidates. exit when Current_Group = "UG"; Working_Map := CandidateID_Maps.Empty_Map; @@ -180,9 +181,9 @@ package body Candidates.Containers is for Cursor in Candidate_Data.Iterate loop Working_Candidate := Candidate_Maps.Element (Cursor); My_Candidate_Data.Append - ((Cand_ID => Candidate_Maps.Key (Cursor), - Group => Working_Candidate.Group, - Group_Rank => Working_Candidate.Group_Rank)); + ((Cand_ID => Candidate_Maps.Key (Cursor), + Group => Working_Candidate.Group, + Group_Rank => Working_Candidate.Group_Rank)); end loop; Sorting.Sort (My_Candidate_Data); -- cgit