From 2cc9554f4de05b179fc7a9aa8421559e1c01eaf0 Mon Sep 17 00:00:00 2001 From: BurningWitness Date: Wed, 4 Sep 2024 16:25:48 +0300 Subject: [PATCH] Adding extra construction functions --- src/Data/R2Tree/Double.hs | 18 ++++++++++++++++++ src/Data/R2Tree/Float.hs | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Data/R2Tree/Double.hs b/src/Data/R2Tree/Double.hs index a04dff2..b2ebe5b 100644 --- a/src/Data/R2Tree/Double.hs +++ b/src/Data/R2Tree/Double.hs @@ -81,6 +81,9 @@ module Data.R2Tree.Double -- * Construct , empty , singleton + , doubleton + , tripleton + , quadrupleton -- ** Bulk-loading , bulkSTR @@ -163,3 +166,18 @@ empty = Empty -- Tree with a single entry. singleton :: MBR -> a -> R2Tree a singleton = Leaf1 + +-- | \(\mathcal{O}(1)\). +-- Tree with two entries. +doubleton :: MBR -> a -> MBR -> a -> R2Tree a +doubleton = Leaf2 + +-- | \(\mathcal{O}(1)\). +-- Tree with three entries. +tripleton :: MBR -> a -> MBR -> a -> MBR -> a -> R2Tree a +tripleton = Leaf3 + +-- | \(\mathcal{O}(1)\). +-- Tree with four entries. +quadrupleton :: MBR -> a -> MBR -> a -> MBR -> a -> MBR -> a -> R2Tree a +quadrupleton = Leaf4 diff --git a/src/Data/R2Tree/Float.hs b/src/Data/R2Tree/Float.hs index 6953e8a..ba863c9 100644 --- a/src/Data/R2Tree/Float.hs +++ b/src/Data/R2Tree/Float.hs @@ -21,6 +21,9 @@ module Data.R2Tree.Float -- * Construct , empty , singleton + , doubleton + , tripleton + , quadrupleton -- ** Bulk-loading , bulkSTR @@ -103,3 +106,18 @@ empty = Empty -- Tree with a single entry. singleton :: MBR -> a -> R2Tree a singleton = Leaf1 + +-- | \(\mathcal{O}(1)\). +-- Tree with two entries. +doubleton :: MBR -> a -> MBR -> a -> R2Tree a +doubleton = Leaf2 + +-- | \(\mathcal{O}(1)\). +-- Tree with three entries. +tripleton :: MBR -> a -> MBR -> a -> MBR -> a -> R2Tree a +tripleton = Leaf3 + +-- | \(\mathcal{O}(1)\). +-- Tree with four entries. +quadrupleton :: MBR -> a -> MBR -> a -> MBR -> a -> MBR -> a -> R2Tree a +quadrupleton = Leaf4