diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-02-08 11:25:34 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-02-08 11:25:34 +1100 |
commit | 964a28e91593c4bf1e1c132536828d87f8d12c84 (patch) | |
tree | a386b12bdca1a18de5d09d80111facb0eaf6979b /src/bundles.ads | |
parent | f0a4bac4bde861bc639c8eca48682f96d7a751be (diff) |
Bundles mostly done, still need to adapt Preferences and Candidates packages
Diffstat (limited to 'src/bundles.ads')
-rw-r--r-- | src/bundles.ads | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/src/bundles.ads b/src/bundles.ads index aa0b0d6..db6565d 100644 --- a/src/bundles.ads +++ b/src/bundles.ads @@ -1,33 +1,57 @@ +with Preferences; with Candidates; with Rationals; -private with Ada.Containers.Vectors; +with Ada.Containers.Ordered_Maps; +with Ada.Containers.Vectors; generic - Number_Of_Candidates : Positive; + with package Given_Prefs is new Preferences (<>); package Bundles is type Bundle is private; - subtype Preference_Array is array (1 .. Number_Of_Candidates) of Candidates.CandidateID; Empty_Bundle : constant Bundle; + package Bundle_Vectors is new Ada.Containers.Vectors with + (Index_Type => Positive, + Element_Type => Bundle); + + + package Bundle_Maps is new Ada.Containers.Ordered_Maps + (Key_Type => Candidates.CandidateID, + Element_Type => Bundle_Vectors.Vector); + + + procedure Read_Bundles + (Filename : in String; + Result : out Bundle_Maps.Map); + + procedure Add (To : in out Bundle; - Item : in Preference_Array); + Item : in Given_Prefs.Preference_Array); procedure Transfer - (From, To : in out Bundle; - Value : in Rationals.Fraction); + (This : in out Bundle; + From, To : in Candidates.CandidateID; + Excluded : in Candidates.CandidateID_Vector; + Value : in Rationals.Fraction; + Result : out Bundle); - function Count + function Count_Votes + (This : in Bundle) + return Natural; + + + function Count_Papers (This : in Bundle) return Natural; @@ -35,17 +59,24 @@ package Bundles is private + use type Rationals.Fraction; + + type Paper_Lot is record How_Many : Positive := 1; - Prefs : Preference_Array; + Prefs : Given_Prefs.Preference_Array; end record; - type Bundle is record - + package Paper_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, + Element_Type => Paper_Lot); - Empty_Bundle := + type Bundle is record + Papers : Paper_Vectors.Vector := Paper_Vectors.Empty_Vector; + Worth : Rationals.Fraction := 1 / 1; + end record; end Bundles; |