Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype InsertionOnly static a = InsertionOnly [Maybe (static a)]
- empty :: InsertionOnly static a
- class LogarithmicMethodDS static a where
- insert :: LogarithmicMethodDS static a => a -> InsertionOnly static a -> InsertionOnly static a
- queryWith :: Monoid m => (static a -> m) -> InsertionOnly static a -> m
Documentation
newtype InsertionOnly static a 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 :: InsertionOnly static a Source #
Builds an empty structure
class LogarithmicMethodDS static a where Source #
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 :: 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 :: 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.