persistent-map-0.3.5: A thread-safe (STM) persistency interface for finite map types.Source codeContentsIndex
Data.CacheStructure
Portabilitynon-portable (requires STM)
Stabilityexperimental
MaintainerPeter Robinson <thaldyron@gmail.com>
Description
A type class for implementing different caching policies (e.g. LRU, LFU,... ). Should be imported qualified.
Synopsis
class CacheStructure c a where
hit :: a -> c a -> c a
last :: c a -> a
pop :: c a -> (c a, a)
empty :: c a
null :: c a -> Bool
toList :: c a -> [a]
delete :: a -> c a -> c a
member :: a -> c a -> Bool
size :: c a -> Int
popMany :: Int -> c a -> (c a, [a])
data CacheException = CacheException String
Documentation
class CacheStructure c a whereSource
A type class for implementing a caching policy (e.g. LRU)
Methods
hit :: a -> c a -> c aSource
A new element is added to the cache or an already existing element was accessed.
last :: c a -> aSource
Returns the "last" element w.r.t. the caching policy.
pop :: c a -> (c a, a)Source
Removes and returns the "last" element w.r.t. the caching policy.
empty :: c aSource
Creates an empty cache structure.
null :: c a -> BoolSource
Checks for emptyness.
toList :: c a -> [a]Source
Transforms the cache structure to a list.
delete :: a -> c a -> c aSource
An element is deleted.
member :: a -> c a -> BoolSource
Checks if an element is in the cache structure.
size :: c a -> IntSource
Returns the size. Should be O(1).
popMany :: Int -> c a -> (c a, [a])Source
Runs pop a number of times. Has a default implementation.
show/hide Instances
data CacheException Source
Constructors
CacheException String
show/hide Instances
Produced by Haddock version 2.4.2