diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-08 19:08:04 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-08 19:08:04 +0400 |
commit | 7bbd628732ec65f9428d7792aa265152a88b5483 (patch) | |
tree | 3179ec440e8016830b0634c2edad92bde4c3ce88 /src/Data/Bitfield.hs | |
parent | 55f7a4944ed4642d988c2634807ca2c4d74cd369 (diff) |
+ Add some docs.
Diffstat (limited to 'src/Data/Bitfield.hs')
-rw-r--r-- | src/Data/Bitfield.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Data/Bitfield.hs b/src/Data/Bitfield.hs index 7cd07123..1ceaf78b 100644 --- a/src/Data/Bitfield.hs +++ b/src/Data/Bitfield.hs | |||
@@ -56,6 +56,7 @@ import Data.Monoid | |||
56 | import Data.Ratio | 56 | import Data.Ratio |
57 | 57 | ||
58 | 58 | ||
59 | -- | Pieces indexed from zero up to 'PieceCount' value. | ||
59 | type PieceIx = Int | 60 | type PieceIx = Int |
60 | 61 | ||
61 | -- | Used to represent max set bound. Min set bound is always set to | 62 | -- | Used to represent max set bound. Min set bound is always set to |
@@ -162,7 +163,8 @@ frequencies xs = runST $ do | |||
162 | 163 | ||
163 | -- TODO it seems like this operation is veeery slow | 164 | -- TODO it seems like this operation is veeery slow |
164 | 165 | ||
165 | -- | Find least available piece index. If no piece available return 'Nothing'. | 166 | -- | Find least available piece index. If no piece available return |
167 | -- 'Nothing'. | ||
166 | rarest :: [Bitfield] -> Maybe PieceIx | 168 | rarest :: [Bitfield] -> Maybe PieceIx |
167 | rarest xs | 169 | rarest xs |
168 | | V.null freqMap = Nothing | 170 | | V.null freqMap = Nothing |
@@ -170,7 +172,9 @@ rarest xs | |||
170 | where | 172 | where |
171 | freqMap = frequencies xs | 173 | freqMap = frequencies xs |
172 | 174 | ||
173 | minIx :: PieceIx -> Frequency -> (PieceIx, Frequency) -> (PieceIx, Frequency) | 175 | minIx :: PieceIx -> Frequency |
176 | -> (PieceIx, Frequency) | ||
177 | -> (PieceIx, Frequency) | ||
174 | minIx ix fr acc@(_, fra) | 178 | minIx ix fr acc@(_, fra) |
175 | | fr < fra && fr > 0 = (ix, fr) | 179 | | fr < fra && fr > 0 = (ix, fr) |
176 | | otherwise = acc | 180 | | otherwise = acc |
@@ -201,7 +205,7 @@ difference a b = Bitfield { | |||
201 | , bfSet = bfSet a `S.difference` bfSet b | 205 | , bfSet = bfSet a `S.difference` bfSet b |
202 | } | 206 | } |
203 | 207 | ||
204 | -- | | 208 | -- | Find indices the any of the peers have. |
205 | unions :: [Bitfield] -> Bitfield | 209 | unions :: [Bitfield] -> Bitfield |
206 | unions = foldl' union (haveNone 0) | 210 | unions = foldl' union (haveNone 0) |
207 | 211 | ||