summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Counter.hs7
-rw-r--r--src/Election.hs1
-rw-r--r--src/Storage.hs8
3 files changed, 11 insertions, 5 deletions
diff --git a/src/Counter.hs b/src/Counter.hs
index 0f3e0d9..bc23671 100644
--- a/src/Counter.hs
+++ b/src/Counter.hs
@@ -54,12 +54,15 @@ createSenateCounter f a b = do
let prefs = parseRawLine a b t0
result = Maybe.fromJust prefs
if (Maybe.isJust prefs)
- then Vec.setPrefs prefStore n result >> readFunc (n + 1) (p + 1)
+ then Vec.setPrefs prefStore (p + 1) result >> readFunc (n + 1) (p + 1)
else readFunc (n + 1) p
p <- readFunc 1 0
IO.hClose h
- return (SenateCounter prefStore b p)
+ return (SenateCounter
+ { prefData = prefStore
+ , ballotMap = b
+ , numBallots = p })
diff --git a/src/Election.hs b/src/Election.hs
index 582b29e..ff9706b 100644
--- a/src/Election.hs
+++ b/src/Election.hs
@@ -300,7 +300,6 @@ doVoteTransfer e = do
--- needs to properly mark the order that the last candidates were elected
-- needs to be modified to take into account ties
checkNoQuota :: Election -> ET.EitherT Election IO Election
checkNoQuota e = do
diff --git a/src/Storage.hs b/src/Storage.hs
index 295273b..be9b8af 100644
--- a/src/Storage.hs
+++ b/src/Storage.hs
@@ -28,7 +28,9 @@ data Store = Store
createStore :: Int -> Int -> IO Store
createStore maxCapacity ballotSize = do
v <- Vec.replicate (maxCapacity * ballotSize) 0
- return (Store v ballotSize)
+ return (Store
+ { getPointer = v
+ , getBallotSize = ballotSize })
@@ -42,7 +44,9 @@ setPref prefStore ballot (position,rank) = do
setPrefs :: Store -> Int -> [Preference] -> IO ()
-setPrefs prefStore ballot prefList =
+setPrefs prefStore ballot prefList = do
+ let blank = take (getBallotSize prefStore) (zip [1..] (cycle [0]))
+ mapM_ (setPref prefStore ballot) blank
mapM_ (setPref prefStore ballot) prefList