Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | GHC2021 |
Synopsis
- newtype InsertionOnly (static :: k -> Type) (a :: k) = InsertionOnly [Maybe (static a)]
- empty :: forall {k} (static :: k -> Type) (a :: k). InsertionOnly static a
- class LogarithmicMethodDS (static :: Type -> Type) a where
- insert :: forall (static :: Type -> Type) a. LogarithmicMethodDS static a => a -> InsertionOnly static a -> InsertionOnly static a
- queryWith :: forall {k} m static (a :: k). Monoid m => (static a -> m) -> InsertionOnly static a -> m
Documentation
newtype InsertionOnly (static :: k -> Type) (a :: k) Source #
Represents an insertion-only data structure built from static data structures.
In particular, we maintain \(O(\log n)\) static data structures of sizes \(2^i\), for \(i \in [0..c\log n]\).
InsertionOnly [Maybe (static a)] |
Instances
empty :: forall {k} (static :: k -> Type) (a :: k). InsertionOnly static a Source #
Builds an empty structure
class LogarithmicMethodDS (static :: Type -> Type) a where Source #
Class representing data structures that can be constructed using the Logarithmic method.
singleton :: a -> static a Source #
Create a new static data structure storing only one value.
build :: NonEmpty a -> static a Source #
Given a NonEmpty list of a's build a static a.
merge :: static a -> static a -> static a Source #
Merges two structurs of the same size. Has a default implementation via build in case the static structure is Foldable1.
insert :: forall (static :: Type -> Type) a. LogarithmicMethodDS static a => a -> InsertionOnly static a -> InsertionOnly static a Source #
Inserts an element into the data structure
running time: \(O(M(n)\log n / n)\), where \(M(n)\) is the time required to merge two data structures of size \(n\).
queryWith :: forall {k} m static (a :: k). Monoid m => (static a -> m) -> InsertionOnly static a -> m Source #
Given a decomposable query algorithm for the static structure, lift it to a query algorithm on the insertion only structure.
pre: (As indicated by the Monoid constraint), the query answer should be decomposable. I.e. we should be able to anser the query on a set \(A \cup B\) by answering the query on \(A\) and \(B\) separately, and combining their results.
running time: \(O(Q(n)\log n)\), where \(Q(n)\) is the query time on the static structure.