| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Radix1Tree.Word8.Strict.Unsafe
Description
Data structure internals, helper operations and unsafe functions.
Synopsis
- data Radix1Tree a
- = Bin !Prefix !(Radix1Tree a) !(Radix1Tree a)
- | Tip !ByteArray !(Maybe a) !(Radix1Tree a)
- | Nil
- type Prefix = Word8
- type Key = Word8
- beyond :: Prefix -> Key -> Bool
- upper :: Prefix -> Key
- lower :: Prefix -> Key
- type Mask = Word8
- zeroBit :: Key -> Mask -> Bool
- mask :: Key -> Mask -> Prefix
- branchingBit :: Prefix -> Prefix -> Mask
- data MalformedTree = MalformedTree String String
- data Lookup1 a = Lookup1 !Build1 a
- unsafeLookupMin :: Radix1Tree a -> (# a #)
- unsafeLookupMinWithKey :: Radix1Tree a -> Lookup1 a
- unsafeLookupMax :: Radix1Tree a -> (# a #)
- unsafeLookupMaxWithKey :: Radix1Tree a -> Lookup1 a
- unsafeAdjustMin :: (a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMin' :: (a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMinWithKey :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMinWithKey' :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMax :: (a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMax' :: (a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMaxWithKey :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeAdjustMaxWithKey' :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a
- unsafeDeleteMin :: Radix1Tree a -> Radix1Tree a
- unsafeDeleteMax :: Radix1Tree a -> Radix1Tree a
- unsafeUpdateMin :: (a -> Maybe a) -> Radix1Tree a -> Radix1Tree a
- unsafeUpdateMinWithKey :: (Build1 -> a -> Maybe a) -> Radix1Tree a -> Radix1Tree a
- unsafeUpdateMax :: (a -> Maybe a) -> Radix1Tree a -> Radix1Tree a
- unsafeUpdateMaxWithKey :: (Build1 -> a -> Maybe a) -> Radix1Tree a -> Radix1Tree a
- data ViewL1 a = ViewL1 !Build1 a !(Radix1Tree a)
- unsafeMinView :: Radix1Tree a -> ViewL1 a
- data ViewR1 a = ViewR1 !(Radix1Tree a) !Build1 a
- unsafeMaxView :: Radix1Tree a -> ViewR1 a
- merge :: (Build1 -> a -> b -> Maybe c) -> (Build1 -> a -> Maybe c) -> (Build -> Radix1Tree a -> Radix1Tree c) -> (Build1 -> b -> Maybe c) -> (Build -> Radix1Tree b -> Radix1Tree c) -> Radix1Tree a -> Radix1Tree b -> Radix1Tree c
Documentation
data Radix1Tree a Source #
Spine-strict radix tree with non-empty byte sequences as keys.
Constructors
| Bin | |
Fields
| |
| Tip | |
Fields
| |
| Nil | |
Instances
Bit operations
Compare
beyond :: Prefix -> Key -> Bool Source #
\(\mathcal{O}(1)\). Whether the key does not match the prefix.
Create
Exceptions
data MalformedTree Source #
Exception thrown by functions that need to return a value, but instead find an invariant-breaking empty node.
Constructors
| MalformedTree | |
Instances
| Exception MalformedTree Source # | |
Defined in Radix.Exception Methods toException :: MalformedTree -> SomeException # fromException :: SomeException -> Maybe MalformedTree # displayException :: MalformedTree -> String # | |
| Show MalformedTree Source # | |
Defined in Radix.Exception Methods showsPrec :: Int -> MalformedTree -> ShowS # show :: MalformedTree -> String # showList :: [MalformedTree] -> ShowS # | |
Edges
Lookup
Key together with the value.
Min
unsafeLookupMin :: Radix1Tree a -> (# a #) Source #
\(\mathcal{O}(k)\). Look up a value at the leftmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeLookupMinWithKey :: Radix1Tree a -> Lookup1 a Source #
\(\mathcal{O}(k)\). Look up a value at the leftmost key in the tree.
Throws MalformedTree if the tree is empty.
Max
unsafeLookupMax :: Radix1Tree a -> (# a #) Source #
\(\mathcal{O}(k)\). Look up a value at the rightmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeLookupMaxWithKey :: Radix1Tree a -> Lookup1 a Source #
\(\mathcal{O}(k)\). Look up a value at the rightmost key in the tree.
Throws MalformedTree if the tree is empty.
Map
Min
unsafeAdjustMin :: (a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the leftmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeAdjustMin' :: (a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the leftmost key in the tree.
New value is evaluated to WHNF.
Throws MalformedTree if the tree is empty.
unsafeAdjustMinWithKey :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the leftmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeAdjustMinWithKey' :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the leftmost key in the tree.
New value is evaluated to WHNF.
Throws MalformedTree if the tree is empty.
Max
unsafeAdjustMax :: (a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the rightmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeAdjustMax' :: (a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the rightmost key in the tree.
New value is evaluated to WHNF.
Throws MalformedTree if the tree is empty.
unsafeAdjustMaxWithKey :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the rightmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeAdjustMaxWithKey' :: (Build1 -> a -> a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update a value at the rightmost key in the tree.
New value is evaluated to WHNF.
Throws MalformedTree if the tree is empty.
Delete
unsafeDeleteMin :: Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Delete a value at the leftmost key in the tree.
Throws MalformedTree if the tree is empty.
unsafeDeleteMax :: Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Delete a value at the rightmost key in the tree.
Throws MalformedTree if the tree is empty.
Update
Min
unsafeUpdateMin :: (a -> Maybe a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update or delete a value at the leftmost key in the tree.
unsafeUpdateMinWithKey :: (Build1 -> a -> Maybe a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update or delete a value at the leftmost key in the tree.
Max
unsafeUpdateMax :: (a -> Maybe a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update or delete a value at the rightmost key in the tree.
unsafeUpdateMaxWithKey :: (Build1 -> a -> Maybe a) -> Radix1Tree a -> Radix1Tree a Source #
\(\mathcal{O}(k)\). Update or delete a value at the rightmost key in the tree.
View
Min
The leftmost value with its key and the rest of the tree.
Constructors
| ViewL1 !Build1 a !(Radix1Tree a) |
unsafeMinView :: Radix1Tree a -> ViewL1 a Source #
\(\mathcal{O}(\min(x,k))\). Look up the leftmost value and return it alongside the tree without it.
Throws MalformedTree if the tree is empty.
Max
The rightmost value with its key and the rest of the tree.
Constructors
| ViewR1 !(Radix1Tree a) !Build1 a |
unsafeMaxView :: Radix1Tree a -> ViewR1 a Source #
\(\mathcal{O}(\min(x,k))\). Look up the rightmost value and return it alongside the tree without it.
Throws MalformedTree if the tree is empty.
Full-tree
Merge
Arguments
| :: (Build1 -> a -> b -> Maybe c) | Single value collision |
| -> (Build1 -> a -> Maybe c) | Single left value |
| -> (Build -> Radix1Tree a -> Radix1Tree c) | Left subtree |
| -> (Build1 -> b -> Maybe c) | Single right value |
| -> (Build -> Radix1Tree b -> Radix1Tree c) | Right subtree |
| -> Radix1Tree a | |
| -> Radix1Tree b | |
| -> Radix1Tree c |
\(\mathcal{O}(n_A k_A + n_B k_B)\). General merge of two trees.
Resulting Maybes and Radix1Trees in argument functions are evaluated to WHNF.
This functions inlines when all argument functions are provided.