DimensionalHash 0.1.5.1 → 0.1.5.2
raw patch · 2 files changed
+14/−14 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/DimensionalHash.hs +12/−13
- DimensionalHash.cabal +2/−1
Data/DimensionalHash.hs view
@@ -5,7 +5,7 @@ -- License : BSD3 -- -- Maintainer : Hamrouni Ghassen <ghamrouni@iptechinside.com> --- Stability : +-- Stability : Experimental -- Portability : -- ----------------------------------------------------------------------------- @@ -22,26 +22,26 @@ ------------------------------------------------------------------------ class (Bits a, Integral a) => (MortonNumber a) where - -- | recursevely compute the morton number. + -- | Recursively compute the hash. dimensionalHash :: (Bits a) => [a] -> a dimensionalHash [] = 0 dimensionalHash list - | hachable == True = hash list 0 (bitSize (head list)) + | hashable == True = hash list 0 (bitSize (head list)) | otherwise = error "The list is not hashable." where - hachable = isHashable list + hashable = isHashable list - -- | compute max bit size for the element of the list + -- | Compute max size (in bit) for an element of the list. maxBitSize :: (Bits a) => [a] -> Int maxBitSize list = div (bitSize (head list)) (length list) - -- | compute max size for the element of the list + -- | Compute maximum size for an element of the list. maxSize :: (Bits a) => [a] -> Int maxSize list = 2 ^ (maxBitSize list) - -- | returns true if the list is hashable - -- A list is hashable IIF for every element x the condition : - -- x > (maxSize list) holds true. + -- | Returns true if the list is hashable + -- A list is hashable IIF for every element x : + -- x > (maxSize list) isHashable :: (Bits a) => [a] -> Bool isHashable [x] = True isHashable list = (length filteredList) == 0 @@ -73,7 +73,7 @@ instance MortonNumber Word64 ------------------------------------------------------------------------ --- | recursevely compute the morton number. +-- | Recursively compute the hash. hash :: (Bits a) => [a] -> Int -> Int -> a hash list n precision @@ -82,7 +82,6 @@ | otherwise = 0 ------------------------------------------------------------------------ --- |Return a list have been shifted elements by n + index concatBits :: (Bits a) => [a] -> Int -> a concatBits list n = foldl (\acc x -> acc .|. x) 0 shiftedMap @@ -91,14 +90,14 @@ mapList = map (\x -> (takeBitAt x n)) list ------------------------------------------------------------------------ --- |Return a list have shifted elements by (n + index) +-- | Shift the elements by n + index shiftElements :: (Bits a) => [a] -> Int -> [a] shiftElements [] n = [] shiftElements (x:xs) n = [(shiftL x n)] ++ (shiftElements xs (n+1)) ------------------------------------------------------------------------ --- |Return an element having all bits set to 0, except the bit at index n +-- | Set all bits to 0, except the bit at index n takeBitAt :: (Bits a) => a -> Int -> a takeBitAt x n = x .&. (shiftL 1 n)
DimensionalHash.cabal view
@@ -1,9 +1,10 @@ name: DimensionalHash -version: 0.1.5.1 +version: 0.1.5.2 build-Type: Simple cabal-version: >= 1.6 tested-with: GHC == 7.0.3 license: BSD3 +stability: Experimental license-File: LICENSE author: Ghassen Hamrouni maintainer: ghamrouni@iptechinside.com