linked-list-with-iterator-0.1.1.0: A pure linked list which is mutable through iterators.

Copyright(c) CindyLinz, 2016
LicenseMIT
Maintainercindylinz@gmail.com
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.IterLinkedList.Internal

Description

A pure linked list with is mutable through iterators.

Exported internals.

Synopsis

Documentation

data LinkedList iter value Source #

The list

Constructors

LinkedList 

Fields

Instances

Show value => Show (LinkedList Int value) Source # 

Methods

showsPrec :: Int -> LinkedList Int value -> ShowS #

show :: LinkedList Int value -> String #

showList :: [LinkedList Int value] -> ShowS #

Show value => Show (LinkedList Integer value) Source # 

class IterLinkedList iter where Source #

Polymorphic operations on the list

Minimal complete definition

null, get, (set | modify), next, prev, empty, singleton, insertBefore, insertAfter, delete, toList

Methods

null :: LinkedList iter value -> Bool Source #

See if this list is an empty list. O(1)

get :: iter -> LinkedList iter value -> Maybe value Source #

Get the element value. O(lg N)

get' :: iter -> LinkedList iter value -> value Source #

Get the element value. Get undefined if not found. O(lg N)

set :: iter -> value -> LinkedList iter value -> LinkedList iter value Source #

Set the element value. Return the original list if the iterator is not in the list O(lg N)

modify :: iter -> (value -> value) -> LinkedList iter value -> LinkedList iter value Source #

Modify the element value. Return the original list if the iterator is not in the list O(lg N)

next :: LinkedList iter value -> iter -> iter Source #

Get the next iterator. If the specified iterator is the last one, or isn't in the list, return the original one. O(lg N)

prev :: LinkedList iter value -> iter -> iter Source #

Get the previous iterator. If the specified iterator is the first one, or isn't in the list, return the original one. O(lg N)

empty :: LinkedList iter value Source #

Get an empty list. O(1)

singleton :: value -> LinkedList iter value Source #

Get a list with exactly one element. O(1)

insertBefore :: iter -> value -> LinkedList iter value -> LinkedList iter value Source #

Insert a new element before the specified iterator. If the list is empty, just insert the new element as the only element. If the specified iterator can't be found, prepend the new element to the whole list. O(lg N)

insertAfter :: iter -> value -> LinkedList iter value -> LinkedList iter value Source #

Insert a new element after the specified iterator. If the list is empty, just insert the new element as the only element. If the specified iterator can't be found, append the new element to the whole list. O(lg N)

delete :: iter -> LinkedList iter value -> LinkedList iter value Source #

Delete the specified element from the list. If there's no such element in the list, return the original list. O(lg N)

fromList :: [value] -> LinkedList iter value Source #

Get a LinkedList from a list O(N)

toList :: LinkedList iter value -> [value] Source #

Get a list from a LinkedList O(N lg N)

Instances

IterLinkedList Int Source # 

Methods

null :: LinkedList Int value -> Bool Source #

get :: Int -> LinkedList Int value -> Maybe value Source #

get' :: Int -> LinkedList Int value -> value Source #

set :: Int -> value -> LinkedList Int value -> LinkedList Int value Source #

modify :: Int -> (value -> value) -> LinkedList Int value -> LinkedList Int value Source #

next :: LinkedList Int value -> Int -> Int Source #

prev :: LinkedList Int value -> Int -> Int Source #

empty :: LinkedList Int value Source #

singleton :: value -> LinkedList Int value Source #

insertBefore :: Int -> value -> LinkedList Int value -> LinkedList Int value Source #

insertAfter :: Int -> value -> LinkedList Int value -> LinkedList Int value Source #

delete :: Int -> LinkedList Int value -> LinkedList Int value Source #

fromList :: [value] -> LinkedList Int value Source #

toList :: LinkedList Int value -> [value] Source #

IterLinkedList Integer Source # 

type family LinkedListContainer iter value Source #

The internal container

Instances

firstIter :: LinkedList iter value -> iter Source #

Get the first iterator. If the list is empty, you'll still get an unusable one. You can't get the value from the unusable iterator. O(lg N)

lastIter :: LinkedList iter value -> iter Source #

Get the last iterator. If the list is empty, you'll still get an unusable one. You can't get the value from the unusable iterator. O(lg N)