Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data NodeData v r = NodeData {
- _splitPoint :: !(EndPoint r)
- _range :: !(Range r)
- _assoc :: !v
- splitPoint :: forall v r. Lens' (NodeData v r) (EndPoint r)
- range :: forall v r. Lens' (NodeData v r) (Range r)
- assoc :: forall v r v. Lens (NodeData v r) (NodeData v r) v v
- data LeafData v r = LeafData {
- _atomicRange :: !(AtomicRange r)
- _leafAssoc :: !v
- atomicRange :: forall v r r. Lens (LeafData v r) (LeafData v r) (AtomicRange r) (AtomicRange r)
- leafAssoc :: forall v r v. Lens (LeafData v r) (LeafData v r) v v
- newtype SegmentTree v r = SegmentTree {
- _unSegmentTree :: BinLeafTree (NodeData v r) (LeafData v r)
- unSegmentTree :: forall v r v r. Iso (SegmentTree v r) (SegmentTree v r) (BinLeafTree (NodeData v r) (LeafData v r)) (BinLeafTree (NodeData v r) (LeafData v r))
- class Measured v i => Assoc v i where
- createTree :: NonEmpty r -> v -> SegmentTree v r
- fromIntervals :: (Ord r, Eq p, Assoc v i, IntervalLike i, Monoid v, NumType i ~ r) => (Interval p r -> i) -> NonEmpty (Interval p r) -> SegmentTree v r
- insert :: (Assoc v i, NumType i ~ r, Ord r, IntervalLike i) => i -> SegmentTree v r -> SegmentTree v r
- delete :: (Assoc v i, NumType i ~ r, Ord r, IntervalLike i) => i -> SegmentTree v r -> SegmentTree v r
- search :: (Ord r, Monoid v) => r -> SegmentTree v r -> v
- stab :: Ord r => r -> SegmentTree v r -> [v]
- newtype I a = I {
- _unI :: a
- fromIntervals' :: (Eq p, Ord r) => NonEmpty (Interval p r) -> SegmentTree [I (Interval p r)] r
- newtype Count = Count {}
Documentation
Internal nodes store a split point, the range, and an associated data structure
Leaf nodes store an atomic range, and an associated data structure.
LeafData | |
|
atomicRange :: forall v r r. Lens (LeafData v r) (LeafData v r) (AtomicRange r) (AtomicRange r) Source #
newtype SegmentTree v r Source #
Segment tree on a Fixed set of endpoints
SegmentTree | |
|
unSegmentTree :: forall v r v r. Iso (SegmentTree v r) (SegmentTree v r) (BinLeafTree (NodeData v r) (LeafData v r)) (BinLeafTree (NodeData v r) (LeafData v r)) Source #
class Measured v i => Assoc v i where Source #
Class for associcated data structures
insertAssoc :: i -> v -> v Source #
deleteAssoc :: i -> v -> v Source #
createTree :: NonEmpty r -> v -> SegmentTree v r Source #
Given a sorted list of endpoints, without duplicates, construct a segment tree
\(O(n)\) time
fromIntervals :: (Ord r, Eq p, Assoc v i, IntervalLike i, Monoid v, NumType i ~ r) => (Interval p r -> i) -> NonEmpty (Interval p r) -> SegmentTree v r Source #
Build a SegmentTree
\(O(n \log n)\)
insert :: (Assoc v i, NumType i ~ r, Ord r, IntervalLike i) => i -> SegmentTree v r -> SegmentTree v r Source #
Pre: the interval should have one of the endpoints on which the tree is built.
delete :: (Assoc v i, NumType i ~ r, Ord r, IntervalLike i) => i -> SegmentTree v r -> SegmentTree v r Source #
Delete an interval from the tree
pre: The segment is in the tree!
search :: (Ord r, Monoid v) => r -> SegmentTree v r -> v Source #
Search for all intervals intersecting x
\(O(\log n + k)\) where \(k\) is the output size
stab :: Ord r => r -> SegmentTree v r -> [v] Source #
Returns the associated values of the nodes on the search path to x
\(O(\log n)\)
Interval
Eq a => Eq (I a) Source # | |
Ord a => Ord (I a) Source # | |
Read a => Read (I a) Source # | |
Show a => Show (I a) Source # | |
Generic (I a) Source # | |
NFData a => NFData (I a) Source # | |
IntervalLike a => IntervalLike (I a) Source # | |
Measured [I a] (I a) Source # | |
Eq a => Assoc [I a] (I a) Source # | |
type Rep (I a) Source # | |
type NumType (I a) Source # | |
fromIntervals' :: (Eq p, Ord r) => NonEmpty (Interval p r) -> SegmentTree [I (Interval p r)] r Source #