# Data.Sequence.Ordered

- Package
- purescript-sequences
- Repository
- hdgarrood/purescript-sequences

This module defines a sequence where elements are always kept in order. This enables constant time access to the least and greatest elements, in addition to logarithmic time partitioning.

The module is intended to be imported qualified, to avoid ambiguity or name clashes. For example:

```
import Data.Sequence.Ordered (OrdSeq)
import Data.Sequence.Ordered as OrdSeq
```

### #fromFoldable Source

`fromFoldable :: forall f a. Foldable f => Ord a => f a -> OrdSeq a`

Probably O(n*log(n)), but depends on the Foldable instance. Consruct an
ordered sequence from any any `Foldable`

.

### #intersection Source

`intersection :: forall a. Ord a => OrdSeq a -> OrdSeq a -> OrdSeq a`

O(n*log(n)), where n is the length of the longer sequence. Create a new sequence containing only elements which are common to both sequences.

### #toUnfoldable Source

`toUnfoldable :: forall f. Functor f => Unfoldable f => OrdSeq ~> f`

Probably O(n), but depends on the Unfoldable instance. Unfold an ordered sequence in ascending order.

### #toUnfoldableDescending Source

`toUnfoldableDescending :: forall f a. Functor f => Unfoldable f => OrdSeq a -> f a`

Probably O(n), but depends on the Unfoldable instance. Unfold an ordered sequence in descending order.

### #sort Source

`sort :: forall f a. Functor f => Foldable f => Unfoldable f => Ord a => f a -> f a`

Sort any structure (which has Foldable, Unfoldable, and Functor instances) by converting to an OrdSeq and back again. I am fairly sure this is usually O(n*log(n)), although of course this depends on the Unfoldable and Foldable instances.