| Copyright | (C) Frank Staals | 
|---|---|
| License | see the LICENSE file | 
| Maintainer | Frank Staals | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Data.IndexedDoublyLinkedList
Description
Synopsis
- data DLList s a = DLList {}
 - data Cell = Cell {}
 - emptyCell :: Cell
 - data DLListMonad s b a
 - runDLListMonad :: Vector b -> (forall s. DLListMonad s b a) -> a
 - type Index = Int
 - singletons :: (PrimMonad m, s ~ PrimState m) => Vector b -> m (DLList s b)
 - writeList :: NonEmpty Index -> DLListMonad s b ()
 - valueAt :: Index -> DLListMonad s b b
 - getNext :: Index -> DLListMonad s b (Maybe Index)
 - getPrev :: Index -> DLListMonad s b (Maybe Index)
 - toListFrom :: Index -> DLListMonad s b (NonEmpty Index)
 - toListFromR :: Index -> DLListMonad s b (NonEmpty Index)
 - toListContains :: Index -> DLListMonad s b (NonEmpty Index)
 - toListFromK :: Index -> Int -> DLListMonad s b (NonEmpty Index)
 - toListFromRK :: Index -> Int -> DLListMonad s b (NonEmpty Index)
 - insertAfter :: Index -> Index -> DLListMonad s b ()
 - insertBefore :: Index -> Index -> DLListMonad s b ()
 - delete :: Index -> DLListMonad s b (Maybe Index, Maybe Index)
 - dump :: DLListMonad s a (Vector a, Vector Cell)
 
Documentation
Doubly linked list implemented by a mutable vector. So actually this data type can represent a collection of Linked Lists that can efficiently be concatenated and split.
Supports O(1) indexing, and O(1) insertions, deletions
Instances
| Functor (DLList s) Source # | |
| MonadReader (DLList s b) (DLListMonad s b) Source # | |
Defined in Data.IndexedDoublyLinkedList Methods ask :: DLListMonad s b (DLList s b) # local :: (DLList s b -> DLList s b) -> DLListMonad s b a -> DLListMonad s b a # reader :: (DLList s b -> a) -> DLListMonad s b a #  | |
Cells in the Linked List
data DLListMonad s b a Source #
Monad in which we can use the IndexedDoublyLinkedList.
Instances
runDLListMonad :: Vector b -> (forall s. DLListMonad s b a) -> a Source #
Runs a DLList Computation, starting with singleton values, crated from the input vector.
singletons :: (PrimMonad m, s ~ PrimState m) => Vector b -> m (DLList s b) Source #
Constructs a new DoublyLinkedList. Every element is its own singleton list
writeList :: NonEmpty Index -> DLListMonad s b () Source #
Sets the DoublyLinkedList to the given List.
Indices that do not occur in the list are not touched.
valueAt :: Index -> DLListMonad s b b Source #
Gets the value at Index i
toListFrom :: Index -> DLListMonad s b (NonEmpty Index) Source #
Computes a maximal length list starting from the Given index
running time: \(O(k)\), where \(k\) is the length of the output list
toListFromR :: Index -> DLListMonad s b (NonEmpty Index) Source #
Computes a maximal length list by walking backwards in the DoublyLinkedList, starting from the Given index
running time: \(O(k)\), where \(k\) is the length of the output list
toListContains :: Index -> DLListMonad s b (NonEmpty Index) Source #
Computes a maximal length list that contains the element i.
running time: \(O(k)\), where \(k\) is the length of the output list
toListFromK :: Index -> Int -> DLListMonad s b (NonEmpty Index) Source #
Takes the current element and its k next's
toListFromRK :: Index -> Int -> DLListMonad s b (NonEmpty Index) Source #
Takes the current element and its k prev's
insertAfter :: Index -> Index -> DLListMonad s b () Source #
Inserts the second argument after the first one into the linked list
insertBefore :: Index -> Index -> DLListMonad s b () Source #
Inserts the second argument before the first one into the linked list