fixfile-0.1.0.0: File-backed recursive data structures.

Copyright(C) 2016 Rev. Johnny Healey
LicenseLGPL-3
MaintainerRev. Johnny Healey <rev.null@gmail.com>
Stabilityexperimental
Portabilityunknown
Safe HaskellNone
LanguageHaskell2010

Data.FixFile.BTree

Description

This is a BTree data type that can be used with FixFile. It can be used as a key-value store where the same key can correspond to multiple values. It supports logarithmic insert, lookup, and delete operations.

Synopsis

Documentation

data BTree k v a Source

A Fixed (BTree k v) stores a BTree of key/value pairs.

Instances

Functor (BTree k v) Source 
Foldable (BTree k v) Source 
Traversable (BTree k v) Source 
(Read k, Read v, Read a) => Read (BTree k v a) Source 
(Show k, Show v, Show a) => Show (BTree k v a) Source 
Generic (BTree k v a) Source 
(Binary k, Binary v, Binary a) => Binary (BTree k v a) Source 
type Rep (BTree k v a) Source 

createBTreeFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (BTree k v))) Source

Create a FixFile storing a (BTree k v). The initial value is empty.

openBTreeFile :: (Binary k, Typeable k, Binary v, Typeable v) => FilePath -> IO (FixFile (Ref (BTree k v))) Source

Open a FixFile storing a (BTree k v).

empty :: Fixed g => g (BTree k v) Source

An empty BTree

insertBTree :: (Ord k, Fixed g) => k -> v -> g (BTree k v) -> g (BTree k v) Source

Insert the value v with the key k into a Fixed (BTree k v).

insertBTreeT :: (Ord k, Binary k, Binary v) => k -> v -> Transaction (Ref (BTree k v)) s () Source

lookupBTree :: (Ord k, Fixed g) => k -> g (BTree k v) -> [v] Source

Lookup the values stored for the key k in a Fixed (BTree k v).

lookupBTreeT :: (Ord k, Binary k, Binary v) => k -> Transaction (Ref (BTree k v)) s [v] Source

filterBTree :: (Ord k, Fixed g) => k -> (v -> Bool) -> g (BTree k v) -> g (BTree k v) Source

Filter items from a Fixed (BTree k v) for a key k that match the predicate.

filterBTreeT :: (Ord k, Binary k, Binary v) => k -> (v -> Bool) -> Transaction (Ref (BTree k v)) s () Source

deleteBTree :: (Ord k, Fixed g) => k -> g (BTree k v) -> g (BTree k v) Source

Delete all items for key k from the Fixed (BTree k v).

deleteBTreeT :: (Ord k, Binary k, Binary v) => k -> Transaction (Ref (BTree k v)) s () Source

toListBTree :: (Ord k, Fixed g) => g (BTree k v) -> [(k, v)] Source

Turn a Fixed (BTree k v) into a list of key value tuples.

fromListBTree :: (Ord k, Fixed g) => [(k, v)] -> g (BTree k v) Source

Turn a list of key value tuples into a Fixed (BTree k v).