Copyright | (c) CindyLinz, 2016 |
---|---|
License | MIT |
Maintainer | cindylinz@gmail.com |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
A pure linked list with is mutable through iterators.
Exported internals.
- data LinkedList iter value = LinkedList {
- newKey :: iter
- firstKey :: iter
- lastKey :: iter
- container :: LinkedListContainer iter value
- class IterLinkedList iter where
- type family LinkedListContainer iter value
- firstIter :: LinkedList iter value -> iter
- lastIter :: LinkedList iter value -> iter
Documentation
class IterLinkedList iter where Source #
Polymorphic operations on the list
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)
type family LinkedListContainer iter value Source #
The internal container
type LinkedListContainer Int value Source # | |
type LinkedListContainer Integer value Source # | |
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)