lazyset-0.1.0.0: Set and Map from lazy/infinite lists.

Copyright(c) Carlos Freund 2016
LicenseMIT
Maintainercarlosfreund@gmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Data.Set.Lazy

Contents

Description

A Set that can be created from lazy, ordered, infinite lists.

Synopsis

Documentation

data LazySet a Source #

Constructors

LazySet [Set a] 

Instances

Eq a => Eq (LazySet a) Source # 

Methods

(==) :: LazySet a -> LazySet a -> Bool #

(/=) :: LazySet a -> LazySet a -> Bool #

Show a => Show (LazySet a) Source # 

Methods

showsPrec :: Int -> LazySet a -> ShowS #

show :: LazySet a -> String #

showList :: [LazySet a] -> ShowS #

Query

member :: Ord a => a -> LazySet a -> Bool Source #

Checks if the value is a member of the LazySet. Performance: O(m)=log m Where m is the position of the element beeing searched for. This only applies after the element has been fetched from the underlying list.

lookup :: Ord a => a -> LazySet a -> Maybe a Source #

Searches for a value in a Set. If it can not be found returns Nothing otherwhise Returns 'Just a' if it can find it. The returned value will be the one from the set, not the one that was passed.

null :: LazySet a -> Bool Source #

Returns true if the LazSet is empty.

size :: Ord a => LazySet a -> Int Source #

Returns the size of the set. Do not use this on infinite Sets.

Combine

spanAntitone :: Ord a => (a -> Bool) -> LazySet a -> (LazySet a, LazySet a) Source #

Splits the LazySet into two parts. The first containing all consecutive elements of the Set where the predicate applies. The second contains the (infinite) rest.

union :: Ord a => LazySet a -> LazySet a -> LazySet a Source #

Union of two LazySets.

Build

empty :: Ord a => LazySet a Source #

Create an empty LazySet.

fromAscList :: Ord a => [a] -> LazySet a Source #

Builds a LazySet from an ascending ordered list. If the list is not ordered an error is thrown.

growFromAscList Source #

Arguments

:: Ord a 
=> Float

The factor by which the subtrees grow. Must be >= 1.0. A growth of 1.0 makes the LazySet behave like a List. The higher it is set, the more it behaves like a Set. The downside of a higher growth-factor is that bigger batches are extracted from the source-list at once.

-> [a]

An ascending List

-> LazySet a 

Like fromAscList but with a custom growth-factor.

fromList :: Ord a => [a] -> LazySet a Source #

Alias for fromAscList.

fromDescList :: Ord a => [a] -> LazySet (Down a) Source #

Create a LazSet from a descending list.

build Source #

Arguments

:: Ord a 
=> Int

starting-depth

-> Float

growth-factor

-> [a]

Ascending source-list

-> [Set a] 

Kind of internal.

Export

toList :: Ord a => LazySet a -> [a] Source #

List with all elements in order.