summaryrefslogtreecommitdiff
path: root/src/bundles.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/bundles.ads')
-rw-r--r--src/bundles.ads53
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;