import Data.Map.Internal.Debug (showTree) import qualified Data.Map.Strict as Map import Hash2Pub.FediChord giebMalCache :: [Integer] -> Map.Map NodeID () giebMalCache = Map.fromList . fmap (mkCacheEntry . fromInteger) where mkCacheEntry nodeid = (nodeid, ()) testCache1 = giebMalCache [1, -1, 2^50] testFirstHalf = giebMalCache [3, 2^254-2, 2^255] testOverlap = giebMalCache [2^255+2^254+3, 2, 2^253] nidLookup m = flip Map.lookup m . fromInteger nidLookupLT m = flip Map.lookupLT m . fromInteger nidLookupGT m = flip Map.lookupGT m . fromInteger edgeCase1 :: IO () edgeCase1 = do putStrLn "Let there be a Map with the keys [2^255+2^254+3, 2, 2^253], all keys are NodeIDs mod 2^256." print testOverlap putStrLn "\nWhile (NodeID 2^255+2^254+3) > (NodeID 2^254 + 14) …" print $ toNodeID (2^255+2^254+3) > toNodeID (2^254+14) putStrLn "… and 2^255+2^254+3 is an element of the map…" print $ Map.member (fromInteger (2^255+2^254+3)) testOverlap putStrLn "… looking for an element larger than 2^254 + 14 doesn't yield any." print $ nidLookupGT testOverlap (2^254+14) putStrLn "\nThat's the tree of the map:" putStrLn $ showTree testOverlap