hgeometry-0.6.0.0: Geometric Algorithms, Data structures, and Data types.

Safe HaskellNone
LanguageHaskell2010

Data.Geometry.IntervalTree

Synopsis

Documentation

data NodeData i r Source #

Information stored in a node of the Interval Tree

Constructors

NodeData 

Fields

Instances

(Eq i, Eq r) => Eq (NodeData i r) Source # 

Methods

(==) :: NodeData i r -> NodeData i r -> Bool #

(/=) :: NodeData i r -> NodeData i r -> Bool #

(Ord i, Ord r) => Ord (NodeData i r) Source # 

Methods

compare :: NodeData i r -> NodeData i r -> Ordering #

(<) :: NodeData i r -> NodeData i r -> Bool #

(<=) :: NodeData i r -> NodeData i r -> Bool #

(>) :: NodeData i r -> NodeData i r -> Bool #

(>=) :: NodeData i r -> NodeData i r -> Bool #

max :: NodeData i r -> NodeData i r -> NodeData i r #

min :: NodeData i r -> NodeData i r -> NodeData i r #

(Show i, Show r) => Show (NodeData i r) Source # 

Methods

showsPrec :: Int -> NodeData i r -> ShowS #

show :: NodeData i r -> String #

showList :: [NodeData i r] -> ShowS #

Generic (NodeData i r) Source # 

Associated Types

type Rep (NodeData i r) :: * -> * #

Methods

from :: NodeData i r -> Rep (NodeData i r) x #

to :: Rep (NodeData i r) x -> NodeData i r #

(NFData i, NFData r) => NFData (NodeData i r) Source # 

Methods

rnf :: NodeData i r -> () #

type Rep (NodeData i r) Source # 
type Rep (NodeData i r) = D1 (MetaData "NodeData" "Data.Geometry.IntervalTree" "hgeometry-0.6.0.0-ODn7ZyBfwj6IkLPAAzetJ" False) (C1 (MetaCons "NodeData" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_splitPoint") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 r)) ((:*:) (S1 (MetaSel (Just Symbol "_intervalsLeft") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map (L r) [i]))) (S1 (MetaSel (Just Symbol "_intervalsRight") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map (R r) [i]))))))

splitPoint :: forall i r. Lens' (NodeData i r) r Source #

intervalsLeft :: forall i r. Lens' (NodeData i r) (Map (L r) [i]) Source #

intervalsRight :: forall i r. Lens' (NodeData i r) (Map (R r) [i]) Source #

newtype IntervalTree i r Source #

IntervalTree type, storing intervals of type i

Constructors

IntervalTree 

Instances

(Eq r, Eq i) => Eq (IntervalTree i r) Source # 

Methods

(==) :: IntervalTree i r -> IntervalTree i r -> Bool #

(/=) :: IntervalTree i r -> IntervalTree i r -> Bool #

(Show r, Show i) => Show (IntervalTree i r) Source # 
Generic (IntervalTree i r) Source # 

Associated Types

type Rep (IntervalTree i r) :: * -> * #

Methods

from :: IntervalTree i r -> Rep (IntervalTree i r) x #

to :: Rep (IntervalTree i r) x -> IntervalTree i r #

(NFData r, NFData i) => NFData (IntervalTree i r) Source # 

Methods

rnf :: IntervalTree i r -> () #

type Rep (IntervalTree i r) Source # 
type Rep (IntervalTree i r) = D1 (MetaData "IntervalTree" "Data.Geometry.IntervalTree" "hgeometry-0.6.0.0-ODn7ZyBfwj6IkLPAAzetJ" True) (C1 (MetaCons "IntervalTree" PrefixI True) (S1 (MetaSel (Just Symbol "_unIntervalTree") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (BinaryTree (NodeData i r)))))

unIntervalTree :: forall i r i r. Iso (IntervalTree i r) (IntervalTree i r) (BinaryTree (NodeData i r)) (BinaryTree (NodeData i r)) Source #

class IntervalLike i where Source #

Anything that looks like an interval

Minimal complete definition

toRange

Methods

toRange :: i -> Range (NumType i) Source #

Instances

createTree :: Ord r => [r] -> IntervalTree i r Source #

Given an ordered list of points, create an interval tree

\(O(n)\)

fromIntervals :: (Ord r, IntervalLike i, NumType i ~ r) => [i] -> IntervalTree i r Source #

Build an interval tree

\(O(n \log n)\)

insert :: (Ord r, IntervalLike i, NumType i ~ r) => i -> IntervalTree i r -> IntervalTree i r Source #

Insert : pre: the interval intersects some midpoint in the tree

\(O(\log n)\)

delete :: (Ord r, IntervalLike i, NumType i ~ r, Eq i) => i -> IntervalTree i r -> IntervalTree i r Source #

Delete an interval from the Tree

\(O(\log n)\) (under some general position assumption)

stab :: Ord r => r -> IntervalTree i r -> [i] Source #

Find all intervals that stab x

\(O(\log n + k)\), where k is the output size

search :: Ord r => r -> IntervalTree i r -> [i] Source #

Find all intervals that stab x

\(O(\log n + k)\), where k is the output size

toList :: IntervalTree i r -> [i] Source #

Lists the intervals. We don't guarantee anything about the order

running time: \(O(n)\).