splay-0.0.6: Generic splay-based sequence representation

Copyright(c) dramforever 2015
Portabilitynon-portable (GHC extensions)
Safe HaskellNone



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.



data Seq a Source

General purpose finite sequences


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 larger than the length of s, (s, mempty) will be returned