You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For performance reasons, this should probably copy ideas and some (modified) code from the fingertree package, but not use its actual FingerTree type. Here's the general idea:
dataMinMaxk=MinMax{smallest::!k
, largest::!k}instanceOrdk=>Semigroup (MinMaxk) whereMinMax min1 max1 <>MinMax min2 max2
=MinMax (min min1 min2) (max max1 max2)
dataEntrykv=Entry!kvdataDigita=One!a | Two!a!a | Three!a!a!a | Four!a!a!a!adataNodeka=Node2{-# UNPACK #-} !(MinMaxk) !a!a
| Node3{-# UNPACK #-} !(MinMaxk) !a!a!adataFingerTreeka=Single!a
| Deep{-# UNPACK #-} !(MinMaxk) !(Digita) (FingerTreek (Nodeka)) !(Digita)
-- Cache the values associated with the smallest-- and largest keys so the smallest and largest entries-- can be viewed in constant time. This is optional.dataDEPQkv=Empty
| DEPQ{valMin::v
, valMax::v
, FingerTreek (Entrykv) }
The code for meld can be copied from the code for >< in fingertree, but using <> instead of mappend and being stricter in the spine than what that package currently does (it will probably be fixed soon). The code for minView and maxView should be similar to the code for Data.Sequence.deleteAt, but using the search procedure in fingertree.
Aha! We can actually do something simpler. We should only need a one-fingered tree. Moreover, we don't need to be able to pop off the entry by the finger particularly quickly, so we can reduce the number of digits without deepening the trees (1 digits can be considered "safe"). So using most of the definitions above, I think we can write
For performance reasons, this should probably copy ideas and some (modified) code from the
fingertree
package, but not use its actualFingerTree
type. Here's the general idea:The code for
meld
can be copied from the code for><
infingertree
, but using<>
instead ofmappend
and being stricter in the spine than what that package currently does (it will probably be fixed soon). The code forminView
andmaxView
should be similar to the code forData.Sequence.deleteAt
, but using the search procedure infingertree
.This implementation should offer:
insert
: persistently amortized O(1); worst-case O(log n).minView
,maxView
: O(log n)meld
: O(log n)The text was updated successfully, but these errors were encountered: