haskus-utils-0.8.0.0: Haskus utility modules

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.STM.TList

Description

Transactional list

Synopsis

Documentation

data TList a Source #

A double linked-list

data TNode a Source #

A node in the list

Every list has a marker node whose value is Nothing. Its nodePrev links to the last node and its nodeNext links to the first node.

empty :: STM (TList a) Source #

Empty node singleton

singleton :: e -> STM (TList e) Source #

Create a singleton list

null :: TList e -> STM Bool Source #

Indicate if the list is empty

length :: TList e -> STM Word Source #

Count the number of elements in the list (0(n))

first :: TList e -> STM (Maybe (TNode e)) Source #

Get the first element if any

last :: TList e -> STM (Maybe (TNode e)) Source #

Get the last element if any

prev :: TNode a -> STM (Maybe (TNode a)) Source #

Get the previous element if any

next :: TNode a -> STM (Maybe (TNode a)) Source #

Get the next element if any

value :: TNode a -> a Source #

Get value associated with a node

deleteAll :: TList a -> STM () Source #

Remove all the elements of the list (O(1))

delete :: TNode a -> STM () Source #

Delete a element of the list

filter :: (e -> STM Bool) -> TList e -> STM () Source #

Only keep element matching the criterium

find :: (e -> STM Bool) -> TList e -> STM (Maybe (TNode e)) Source #

Find the first node matching the predicate (if any)

append :: a -> TList a -> STM (TNode a) Source #

Append an element to the list

append_ :: a -> TList a -> STM () Source #

Append an element to the list

prepend :: a -> TList a -> STM (TNode a) Source #

Prepend an element to the list

prepend_ :: a -> TList a -> STM () Source #

Prepend an element to the list

insertBefore :: a -> TNode a -> STM (TNode a) Source #

Insert an element before another

insertAfter :: a -> TNode a -> STM (TNode a) Source #

Insert an element after another

toList :: TList a -> STM [a] Source #

Convert into a list (O(n))

toReverseList :: TList a -> STM [a] Source #

Convert into a reversed list (O(n))

fromList :: [e] -> STM (TList e) Source #

Create from a list

index :: Word -> TList e -> STM (Maybe (TNode e)) Source #

Get the node from its index

take :: Word -> TList e -> STM [e] Source #

Take (and remove) up to n elements in the list (O(n))