Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype TCODList a = TCODList {
- unTCODList :: Ptr ()
- listNew :: IO (TCODList a)
- listAllocate :: Int -> IO (TCODList a)
- listDuplicated :: TCODList a -> IO (TCODList a)
- listDelete :: TCODList a -> IO ()
- listPush :: Storable a => TCODList a -> a -> IO ()
- listPushPtr :: TCODList a -> Ptr a -> IO ()
- listPop :: Storable a => TCODList a -> IO (Maybe a)
- listPopPtr :: TCODList a -> IO (Ptr a)
- listPeek :: Storable a => TCODList a -> IO (Maybe a)
- listPeekPtr :: TCODList a -> IO (Ptr a)
- listAddAll :: TCODList a -> TCODList a -> IO ()
- listGet :: Storable a => TCODList a -> Int -> IO (Maybe a)
- listGetPtr :: TCODList a -> Int -> IO (Ptr a)
- listSet :: Storable a => TCODList a -> a -> Int -> IO ()
- listSetPtr :: TCODList a -> Ptr a -> Int -> IO ()
- listBeginPtr :: TCODList a -> IO (Ptr (Ptr a))
- listEndPtr :: TCODList a -> IO (Ptr (Ptr a))
- listReverse :: TCODList a -> IO ()
- listRemoveIterator :: TCODList a -> Ptr (Ptr a) -> IO (Ptr (Ptr a))
- listRemoveIteratorFast :: TCODList a -> Ptr (Ptr a) -> IO (Ptr (Ptr a))
- listRemovePtr :: TCODList a -> Ptr a -> IO ()
- listRemove :: Storable a => TCODList a -> a -> IO ()
- listRemoveFastPtr :: TCODList a -> Ptr a -> IO ()
- listRemoveFast :: Storable a => TCODList a -> a -> IO ()
- listContainsPtr :: TCODList a -> Ptr a -> IO Bool
- listContains :: Storable a => TCODList a -> a -> IO Bool
- listClear :: TCODList a -> IO ()
- listClearAndDelete :: TCODList a -> IO ()
- listSize :: TCODList a -> IO Int
- listInsertBeforePtr :: TCODList a -> Ptr a -> Int -> IO (Ptr (Ptr a))
- listInsertBefore :: Storable a => TCODList a -> a -> Int -> IO (Ptr (Ptr a))
- listIsEmpty :: TCODList a -> IO Bool
- listToList :: forall a. Storable a => TCODList a -> IO [a]
- listFromList :: forall a f. (Foldable f, Storable a) => f a -> IO (TCODList a)
- listToVectorUnsafe :: forall a. Storable a => TCODList a -> IO (Vector a)
- listToVector :: forall a. Storable a => TCODList a -> IO (Vector a)
Documentation
This is a fast, lightweight and generic container, that provides array, list and stack paradigms.
TCODList | |
|
You can also create an empty list and pre-allocate memory for elements. Use this if you know the list size and want the memory to fit it perfectly.
listDuplicated :: TCODList a -> IO (TCODList a) Source #
You can create a list by duplicating an existing list.
listDelete :: TCODList a -> IO () Source #
You can delete a list, freeing any allocated resources. Note that deleting the list does not delete it's elements. You have to use clearAndDelete before deleting the list if you want to destroy the elements too.
listPush :: Storable a => TCODList a -> a -> IO () Source #
You can push an element on the stack (append it to the end of the list)
listPushPtr :: TCODList a -> Ptr a -> IO () Source #
You can push an element on the stack (append it to the end of the list)
listPop :: Storable a => TCODList a -> IO (Maybe a) Source #
You can pop an element from the stack (remove the last element of the list).
listPopPtr :: TCODList a -> IO (Ptr a) Source #
You can pop an element from the stack (remove the last element of the list).
listPeek :: Storable a => TCODList a -> IO (Maybe a) Source #
You can read the last element of the stack without removing it :
listPeekPtr :: TCODList a -> IO (Ptr a) Source #
You can read the last element of the stack without removing it :
listAddAll :: TCODList a -> TCODList a -> IO () Source #
You can concatenate two lists. Every element of l2 will be added to current list
listGet :: Storable a => TCODList a -> Int -> IO (Maybe a) Source #
You can retrieve a value with get.
listSet :: Storable a => TCODList a -> a -> Int -> IO () Source #
You can assign a value with set. If needed, the array will allocate new elements up to idx.
listSetPtr :: TCODList a -> Ptr a -> Int -> IO () Source #
You can assign a value with set. If needed, the array will allocate new elements up to idx.
listBeginPtr :: TCODList a -> IO (Ptr (Ptr a)) Source #
You can iterate through the elements of the list using an iterator. begin() returns the address of the first element of the list. You go to the next element using the increment operator ++. When the iterator's value is equal to end(), you've gone through all the elements.
Warning ! You cannot insert elements in the list while iterating through it. Inserting elements can result in reallocation of the list and your iterator will not longer be valid.
listEndPtr :: TCODList a -> IO (Ptr (Ptr a)) Source #
You can iterate through the elements of the list using an iterator. begin() returns the address of the first element of the list. You go to the next element using the increment operator ++. When the iterator's value is equal to end(), you've gone through all the elements.
Warning ! You cannot insert elements in the list while iterating through it. Inserting elements can result in reallocation of the list and your iterator will not longer be valid.
listReverse :: TCODList a -> IO () Source #
This function reverses the order of the elements in the list.
listRemoveIterator :: TCODList a -> Ptr (Ptr a) -> IO (Ptr (Ptr a)) Source #
You can remove an element from the list while iterating. The element at the iterator position will be removed. The function returns the new iterator. The _fast versions replace the element to remove with the last element of the list. They're faster, but do not preserve the list order.
listRemoveIteratorFast :: TCODList a -> Ptr (Ptr a) -> IO (Ptr (Ptr a)) Source #
You can remove an element from the list while iterating. The element at the iterator position will be removed. The function returns the new iterator. The _fast versions replace the element to remove with the last element of the list. They're faster, but do not preserve the list order.
listRemoveFastPtr :: TCODList a -> Ptr a -> IO () Source #
The _fast versions replace the element to remove with the last element of the list. They're faster, but do not preserve the list order.
listRemoveFast :: Storable a => TCODList a -> a -> IO () Source #
The _fast versions replace the element to remove with the last element of the list. They're faster, but do not preserve the list order.
listContains :: Storable a => TCODList a -> a -> IO Bool Source #
Checking if an element is in the list
listClearAndDelete :: TCODList a -> IO () Source #
For lists containing pointers, you can clear the list and delete (or free for C) the elements :
listInsertBeforePtr :: TCODList a -> Ptr a -> Int -> IO (Ptr (Ptr a)) Source #
Insert an element in the list
listInsertBefore :: Storable a => TCODList a -> a -> Int -> IO (Ptr (Ptr a)) Source #
Insert an element in the list
Haskell conversion
listFromList :: forall a f. (Foldable f, Storable a) => f a -> IO (TCODList a) Source #
Unload Haskell list to TCOD container O(N)