diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-12 06:34:19 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-12 06:34:19 +0400 |
commit | 8b005c4eb0f58db974c342efe0821240f39a6331 (patch) | |
tree | 85a32db63949ed1082a61100b71fcb830e1044e5 /src/Data/Bitfield.hs | |
parent | 7f27eec9bf34a513f7a28072468706e8975ef552 (diff) |
+ Rename to await and yield.
Diffstat (limited to 'src/Data/Bitfield.hs')
-rw-r--r-- | src/Data/Bitfield.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Data/Bitfield.hs b/src/Data/Bitfield.hs index 9c62e183..18f80a4e 100644 --- a/src/Data/Bitfield.hs +++ b/src/Data/Bitfield.hs | |||
@@ -41,6 +41,8 @@ module Data.Bitfield | |||
41 | , member, notMember | 41 | , member, notMember |
42 | , findMin, findMax | 42 | , findMin, findMax |
43 | 43 | ||
44 | , isSubsetOf | ||
45 | |||
44 | , Frequency, frequencies, rarest | 46 | , Frequency, frequencies, rarest |
45 | 47 | ||
46 | -- * Combine | 48 | -- * Combine |
@@ -182,6 +184,9 @@ findMax Bitfield {..} | |||
182 | | S.null bfSet = Nothing | 184 | | S.null bfSet = Nothing |
183 | | otherwise = Just (S.findMax bfSet) | 185 | | otherwise = Just (S.findMax bfSet) |
184 | 186 | ||
187 | isSubsetOf :: Bitfield -> Bitfield -> Bool | ||
188 | isSubsetOf a b = bfSet a `S.isSubsetOf` bfSet b | ||
189 | |||
185 | -- | Frequencies are needed in piece selection startegies which use | 190 | -- | Frequencies are needed in piece selection startegies which use |
186 | -- availability quantity to find out the optimal next piece index to | 191 | -- availability quantity to find out the optimal next piece index to |
187 | -- download. | 192 | -- download. |
@@ -208,7 +213,8 @@ frequencies xs = runST $ do | |||
208 | rarest :: [Bitfield] -> Maybe PieceIx | 213 | rarest :: [Bitfield] -> Maybe PieceIx |
209 | rarest xs | 214 | rarest xs |
210 | | V.null freqMap = Nothing | 215 | | V.null freqMap = Nothing |
211 | | otherwise = Just $ fst $ V.ifoldr' minIx (0, freqMap V.! 0) freqMap | 216 | | otherwise |
217 | = Just $ fst $ V.ifoldr' minIx (0, freqMap V.! 0) freqMap | ||
212 | where | 218 | where |
213 | freqMap = frequencies xs | 219 | freqMap = frequencies xs |
214 | 220 | ||