splay-0.0.5: Generic splay-based sequence representation

Copyright(c) dramforever 2015
LicenseBSD3
Maintainerdramforever
Stabilityunstable
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.Splay.Sequence

Description

An example implementation of sequences using splay trees.

Some of the names in this module clashes with Prelude functions, so this module should be imported qualified.

Synopsis

Documentation

data Seq a Source

General purpose finite sequences

Instances

Functor Seq 
Foldable Seq 
Traversable Seq 
Eq a => Eq (Seq a) 
Ord a => Ord (Seq a) 
Show a => Show (Seq a) 
Monoid (Seq a) 

singleton :: a -> Seq a Source

Construct a sequence of only one element

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

Add an element to the left end of a sequence

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

Add an element to the right end of a sequence

fromList :: [a] -> Seq a Source

Construct a sequence from a list

Warning: The underlying splay tree created this function will be very unbalanced. However note that the amortized running time of other functions will be unaffected. This is to be fixed in the future.

null :: Seq a -> Bool Source

Is this sequence empty?

length :: Seq a -> Int Source

The number of elements in the sequence

splitAt :: Int -> Seq a -> (Seq a, Seq a) Source

splitAt n s splits s into the first n elements and the rest. If n is less than the length of s, (s, mempty) will be returned