Control.Monad.Memo.Vector (original) (raw)

Contents

Description

VectorCache - mutable-vector-based (IO and ST hosted) [MonadCache](Control-Monad-Memo-Class.html#t:MonadCache "Control.Monad.Memo.Class")

The fastest memoization cache, however it is even more limiting than Control.Monad.Memo.Array due to nature of Data.Vector.Mutable. Still if you can use this cache please do since it will give you dramatic calculation speed up in comparison to pure [Map](/package/containers-0.6.2.1/docs/Data-Map.html#v:Map "Data.Map")-based cache, especially when unboxed [UVectorCache](Control-Monad-Memo-Vector.html#t:UVectorCache "Control.Monad.Memo.Vector") is used.

Limitations: Since [MVector](/package/vector-0.12.3.1/docs/Data-Vector-Generic-Mutable-Base.html#t:MVector "Data.Vector.Generic.Mutable.Base") is used as [MonadCache](Control-Monad-Memo-Class.html#t:MonadCache "Control.Monad.Memo.Class") the key must be [Int](/package/base-4.14.1.0/docs/Data-Int.html#t:Int "Data.Int") and the size of the cache's vector must be known beforehand with vector being allocated before the first call. In addition unboxed [UVectorCache](Control-Monad-Memo-Vector.html#t:UVectorCache "Control.Monad.Memo.Vector") can only store [Unbox](/package/vector-0.12.3.1/docs/Data-Vector-Unboxed.html#v:Unbox "Data.Vector.Unboxed") values (but it does it very efficiently).

Synopsis

VectorCache for boxed types

evalVectorMemo Source #

Evaluate computation using mutable boxed vector

Vector length must covers all possible keys used in computation otherwise index out of bound error is generated by vector code

runVectorMemo Source #

Evaluate computation using mutable boxed vector. It also returns the final content of the vector cache

Vector length must covers all possible keys used in computation otherwise index out of bound error is generated by vector code

UVectorCache for unboxed types

evalUVectorMemo Source #

Evaluate computation using mutable unboxed vector

Vector length must covers all possible keys used in computation otherwise index out of bound error is generated by vector code

runUVectorMemo Source #

Evaluate computation using mutable unboxed vector. It also returns the final content of the vector cache

Vector length must covers all possible keys used in computation otherwise index out of bound error is generated by vector code

Generic functions for VectorCache