diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-07 00:54:09 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-07 00:54:09 +0400 |
commit | 65282d73004fb45b502a5e9bf50359159f6179de (patch) | |
tree | 5ac07d389d1280ea86b2d97540b7841ea1385c88 /src/Data | |
parent | 50454e4cc0af670a3ad68efd828aa505811ed28a (diff) |
+ Add tests for bitfield.
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/Bitfield.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Data/Bitfield.hs b/src/Data/Bitfield.hs index 3424a0c6..a1033ff2 100644 --- a/src/Data/Bitfield.hs +++ b/src/Data/Bitfield.hs | |||
@@ -19,6 +19,7 @@ module Data.Bitfield | |||
19 | , haveAll, haveNone, have | 19 | , haveAll, haveNone, have |
20 | 20 | ||
21 | -- * Query | 21 | -- * Query |
22 | , Data.Bitfield.null | ||
22 | , haveCount, totalCount, completeness | 23 | , haveCount, totalCount, completeness |
23 | , findMin, findMax | 24 | , findMin, findMax |
24 | 25 | ||
@@ -100,6 +101,10 @@ have ix Bitfield {..} | |||
100 | Query | 101 | Query |
101 | -----------------------------------------------------------------------} | 102 | -----------------------------------------------------------------------} |
102 | 103 | ||
104 | -- | Test if bitifield have no one index: peer do not have anything. | ||
105 | null :: Bitfield -> Bool | ||
106 | null Bitfield {..} = S.null bfSet | ||
107 | |||
103 | -- | Count of peer have pieces. | 108 | -- | Count of peer have pieces. |
104 | haveCount :: Bitfield -> PieceCount | 109 | haveCount :: Bitfield -> PieceCount |
105 | haveCount = S.size . bfSet | 110 | haveCount = S.size . bfSet |