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

Data.Seq2

Synopsis

# Documentation

data Seq2 a Source

Basically Data.Sequence but with the guarantee that the list contains at least two elements.

Constructors

 Seq2 a (Seq a) a

Instances

 Source Source Source Eq a => Eq (Seq2 a) Source Ord a => Ord (Seq2 a) Source Read a => Read (Seq2 a) Source Show a => Show (Seq2 a) Source Source Ixed (Seq2 a) Source type Index (Seq2 a) = Int Source type IxValue (Seq2 a) = a Source

duo :: a -> a -> Seq2 a Source

index :: Seq2 a -> Int -> a Source

get the element with index i, counting from the left and starting at 0. O(log(min(i,n-i)))

adjust :: (a -> a) -> Int -> Seq2 a -> Seq2 a Source

(<|) :: a -> Seq2 a -> Seq2 a Source

(|>) :: Seq2 a -> a -> Seq2 a Source

(><) :: Seq2 a -> Seq2 a -> Seq2 a Source

Concatenate two sequences. O(log(min(n1,n2)))

fromList :: [a] -> Seq2 a Source

pre: the list contains at least two elements

mapWithIndex :: (Int -> a -> b) -> Seq2 a -> Seq2 b Source

fmap but with an index

take :: Int -> Seq2 a -> Seq a Source

drop :: Int -> Seq2 a -> Seq a Source

toSeq :: Seq2 a -> Seq a Source

fromSeqUnsafe :: Seq a -> Seq2 a Source

Convert a Seq into a Seq2. It is not checked that the length is at least two

data ViewL2 a Source

Left views

Constructors

 a :<< (ViewR1 a)

Instances

 Source Source Source At least two elements Eq a => Eq (ViewL2 a) Source Ord a => Ord (ViewL2 a) Source Read a => Read (ViewL2 a) Source Show a => Show (ViewL2 a) Source

data ViewL1 a Source

At least one element

Constructors

 a :< (Seq a)

Instances

 Source Source Source Eq a => Eq (ViewL1 a) Source Ord a => Ord (ViewL1 a) Source Read a => Read (ViewL1 a) Source Show a => Show (ViewL1 a) Source Source We throw away information here; namely that the combined list contains two elements.

viewl :: Seq2 a -> ViewL2 a Source

O(1) get a left view

data ViewR2 a Source

Right views

A view of the right end of the seq, with the guarantee that it has at least two elements

Constructors

 (ViewL1 a) :>> a

Instances

 Source Source Source Eq a => Eq (ViewR2 a) Source Ord a => Ord (ViewR2 a) Source Read a => Read (ViewR2 a) Source Show a => Show (ViewR2 a) Source

data ViewR1 a Source

A view of the right end of the sequence, with the guarantee that it has at least one element.

Constructors

 (Seq a) :> a

Instances

 Source Source Source Eq a => Eq (ViewR1 a) Source Ord a => Ord (ViewR1 a) Source Read a => Read (ViewR1 a) Source Show a => Show (ViewR1 a) Source

viewr :: Seq2 a -> ViewR2 a Source

O(1) get a right view