-- finds the indices of hash table entries for a given key
cdbFind :: CDB -> ByteString -> [Word32]
cdbFind cdb key =
  let hash     = cdbHash key
      tableNum = fromIntegral $ hash `mod` 256
      tl       = tableLength cdb tableNum 
      in
      if tl == 0
        then []
        else
          let slotNum = hash `div` 256 `mod` tl
              linearSearch slotNum = case probe cdb tableNum slotNum of
                Just (recordOffset, hash') ->
                  let nextSlot = (slotNum + 1) `mod` tl in
                  if hash == hash' && key == readKey cdb recordOffset
                    then recordOffset : linearSearch nextSlot
                    else linearSearch nextSlot
                Nothing -> []
          in
          linearSearch slotNum
cdbFind :: CDB -> ByteString -> [Word32]
cdbFind cdb key =
  let hash     = cdbHash key
      tableNum = fromIntegral $ hash `mod` 256
      tl       = tableLength cdb tableNum 
      in
      if tl == 0
        then []
        else
          let slotNum = hash `div` 256 `mod` tl
              linearSearch slotNum = case probe cdb tableNum slotNum of
                Just (recordOffset, hash') ->
                  let nextSlot = (slotNum + 1) `mod` tl in
                  if hash == hash' && key == readKey cdb recordOffset
                    then recordOffset : linearSearch nextSlot
                    else linearSearch nextSlot
                Nothing -> []
          in
          linearSearch slotNum
cdbFind cdb key =
  let hash     = cdbHash key
      tableNum = fromIntegral $ hash `mod` 256
      tl       = tableLength cdb tableNum 
      in
      if tl == 0
        then []
        else
          let slotNum = hash `div` 256 `mod` tl
              linearSearch slotNum = case probe cdb tableNum slotNum of
                Just (recordOffset, hash') ->
                  let nextSlot = (slotNum + 1) `mod` tl in
                  if hash == hash' && key == readKey cdb recordOffset
                    then recordOffset : linearSearch nextSlot
                    else linearSearch nextSlot
                Nothing -> []
          in
          linearSearch slotNum