module Data.BTree.Impure (
Tree(..)
, Node(..)
, empty
, fromList
, fromMap
, insertTree
, insertTreeMany
, deleteTree
, lookupTree
, lookupMinTree
, foldr
, foldrM
, foldrWithKey
, foldrWithKeyM
, foldMap
, toList
) where
import Prelude hiding (foldr, foldMap)
import Data.Map (Map)
import qualified Data.Map as M
import Data.BTree.Alloc.Class
import Data.BTree.Impure.Delete (deleteTree)
import Data.BTree.Impure.Structures (Tree(..), Node(..))
import Data.BTree.Impure.Fold (foldr, foldrM, foldrWithKey, foldrWithKeyM, foldMap, toList)
import Data.BTree.Impure.Insert (insertTree, insertTreeMany)
import Data.BTree.Impure.Lookup (lookupTree, lookupMinTree)
import Data.BTree.Primitives
empty :: Tree k v
empty = Tree zeroHeight Nothing
fromList :: (AllocM m, Key k, Value v)
=> [(k, v)]
-> m (Tree k v)
fromList = fromMap . M.fromList
fromMap :: (AllocM m, Key k, Value v)
=> Map k v
-> m (Tree k v)
fromMap kvs = insertTreeMany kvs empty