| 1 |
structure BM = |
| 2 |
struct |
| 3 |
structure W8A = Word8Array |
| 4 |
structure W8 = Word8 |
| 5 |
structure W = Word |
| 6 |
fun create N = W8A.array(W.toIntX(W.>>(W.fromInt(N + 7), 0w3)), 0w0) |
| 7 |
fun markAndTest(bitmap,i) = |
| 8 |
let val byte = W.toIntX(W.>>(W.fromInt i,0w3)) |
| 9 |
val mask = W8.<<(0w1, W.andb(W.fromInt i,0w7)) |
| 10 |
val n = W8A.sub(bitmap, byte) |
| 11 |
in W8.andb(n, mask) <> 0w0 orelse |
| 12 |
(W8A.update(bitmap, byte, W8.orb(n, mask)); false) |
| 13 |
end |
| 14 |
fun contains(bitmap,i) = |
| 15 |
let val byte = W.toIntX(W.>>(W.fromInt i,0w3)) |
| 16 |
val mask = W8.<<(0w1, W.andb(W.fromInt i,0w7)) |
| 17 |
in W8.andb(W8A.sub(bitmap, byte), mask) <> 0w0 end |
| 18 |
end |